pinokiod 2.15.80 → 2.15.82
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/index.js +7 -0
- package/kernel/loader.js +10 -5
- package/package.json +1 -1
- package/server/index.js +14 -2
- package/server/views/browser.ejs +365 -188
- package/server/views/browser-experimental.ejs +0 -1541
package/server/views/browser.ejs
CHANGED
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
<script src="/report.js"></script>
|
|
18
18
|
<script src="/normalize.js"></script>
|
|
19
19
|
<script src="/Socket.js"></script>
|
|
20
|
+
<script src="/noty.js"></script>
|
|
21
|
+
<script src="/notyq.js"></script>
|
|
20
22
|
<% if (agent === "electron") { %>
|
|
21
23
|
<link href="/electron.css" rel="stylesheet"/>
|
|
22
24
|
<% } %>
|
|
@@ -29,12 +31,14 @@
|
|
|
29
31
|
}
|
|
30
32
|
#menu img {
|
|
31
33
|
display: none;
|
|
32
|
-
height:
|
|
34
|
+
height: 30px;
|
|
33
35
|
object-fit: contain;
|
|
36
|
+
/*
|
|
34
37
|
border-radius: 20px
|
|
38
|
+
*/
|
|
35
39
|
}
|
|
36
40
|
#menu.margin {
|
|
37
|
-
padding:
|
|
41
|
+
padding: 5px;
|
|
38
42
|
}
|
|
39
43
|
#menu.margin i {
|
|
40
44
|
display: none;
|
|
@@ -60,6 +64,7 @@ body.dark .m {
|
|
|
60
64
|
border-top: 1px solid rgba(0,0,0,0.04);
|
|
61
65
|
}
|
|
62
66
|
.container {
|
|
67
|
+
position: relative;
|
|
63
68
|
display: flex;
|
|
64
69
|
flex-direction: column;
|
|
65
70
|
flex-grow: 1;
|
|
@@ -85,6 +90,7 @@ aside {
|
|
|
85
90
|
}
|
|
86
91
|
main {
|
|
87
92
|
flex-grow: 1;
|
|
93
|
+
min-height: 0;
|
|
88
94
|
/*
|
|
89
95
|
height: 100%;
|
|
90
96
|
*/
|
|
@@ -125,6 +131,7 @@ body.dark .header-item .btn2 {
|
|
|
125
131
|
}
|
|
126
132
|
.bar .btn2 i {
|
|
127
133
|
display: block;
|
|
134
|
+
margin-right: 5px;
|
|
128
135
|
}
|
|
129
136
|
.header-item > * {
|
|
130
137
|
display: block;
|
|
@@ -202,17 +209,18 @@ body.dark .app-info > * {
|
|
|
202
209
|
display: flex;
|
|
203
210
|
*/
|
|
204
211
|
display: grid;
|
|
205
|
-
grid-template-columns: repeat(
|
|
212
|
+
grid-template-columns: repeat(4, 1fr);
|
|
206
213
|
}
|
|
207
214
|
.footer > * {
|
|
208
|
-
padding:
|
|
215
|
+
padding: 10px !important;
|
|
209
216
|
display: block;
|
|
210
217
|
box-sizing: border-box;
|
|
211
|
-
font-size:
|
|
218
|
+
font-size: 12px !important;
|
|
212
219
|
text-align: center;
|
|
213
220
|
}
|
|
214
221
|
.footer i {
|
|
215
222
|
margin: 0 !important;
|
|
223
|
+
padding: 5px;
|
|
216
224
|
}
|
|
217
225
|
.footer a {
|
|
218
226
|
font-size: 14px;
|
|
@@ -256,6 +264,14 @@ body.dark .frame-link.selected {
|
|
|
256
264
|
padding: 5px;
|
|
257
265
|
*/
|
|
258
266
|
}
|
|
267
|
+
.loader .btn:hover {
|
|
268
|
+
color: royalblue;
|
|
269
|
+
border-color: royalblue;
|
|
270
|
+
}
|
|
271
|
+
.loader .btn {
|
|
272
|
+
padding: 4px 8px;
|
|
273
|
+
border: 1px solid rgba(255,255,255,0.3);
|
|
274
|
+
}
|
|
259
275
|
.frame-link .tab {
|
|
260
276
|
flex-grow: 1;
|
|
261
277
|
/*
|
|
@@ -289,10 +305,11 @@ body.dark .grid-btns {
|
|
|
289
305
|
box-sizing: border-box;
|
|
290
306
|
}
|
|
291
307
|
.grid-btns .btn2 {
|
|
292
|
-
padding: 10px;
|
|
308
|
+
padding: 10px 10px;
|
|
293
309
|
color: var(--light-color);
|
|
294
310
|
border-radius: 0;
|
|
295
311
|
cursor: pointer;
|
|
312
|
+
font-size: 11px;
|
|
296
313
|
}
|
|
297
314
|
body.dark .grid-btns .btn2 {
|
|
298
315
|
/*
|
|
@@ -331,11 +348,29 @@ body.dark nav {
|
|
|
331
348
|
/*
|
|
332
349
|
border-bottom: 1px solid rgba(255,255,255,0.04);
|
|
333
350
|
*/
|
|
334
|
-
border-
|
|
351
|
+
border-top: 1px solid rgba(255,255,255,0.04);
|
|
335
352
|
}
|
|
353
|
+
/*
|
|
354
|
+
.container:hover nav {
|
|
355
|
+
display: block;
|
|
356
|
+
}
|
|
357
|
+
*/
|
|
336
358
|
nav {
|
|
359
|
+
/*
|
|
360
|
+
overflow: hidden;
|
|
361
|
+
max-height: 0;
|
|
362
|
+
transition: max-height 0.4s ease-out;
|
|
363
|
+
display: none;
|
|
364
|
+
*/
|
|
365
|
+
|
|
337
366
|
background: white;
|
|
338
367
|
/*
|
|
368
|
+
position: absolute;
|
|
369
|
+
bottom: 0;
|
|
370
|
+
left: 0;
|
|
371
|
+
right: 0;
|
|
372
|
+
*/
|
|
373
|
+
/*
|
|
339
374
|
padding: 5px;
|
|
340
375
|
*/
|
|
341
376
|
padding: 0;
|
|
@@ -344,17 +379,18 @@ nav {
|
|
|
344
379
|
/*
|
|
345
380
|
border-bottom: 1px solid rgba(0,0,0,0.04);
|
|
346
381
|
*/
|
|
347
|
-
border-
|
|
382
|
+
border-top: 1px solid rgba(0,0,0,0.04);
|
|
348
383
|
box-sizing: border-box;
|
|
349
|
-
display: none;
|
|
350
384
|
}
|
|
351
385
|
body.dark nav .btn2 {
|
|
352
386
|
border-right: 1px solid rgba(255,255,255,0.04);
|
|
353
387
|
}
|
|
354
388
|
nav .btn2 {
|
|
355
|
-
padding:
|
|
389
|
+
padding: 15px;
|
|
356
390
|
font-size: 12px;
|
|
391
|
+
/*
|
|
357
392
|
width: 70px;
|
|
393
|
+
*/
|
|
358
394
|
box-sizing: border-box;
|
|
359
395
|
border-right: 1px solid rgba(0,0,0,0.04);
|
|
360
396
|
border-radius: 0;
|
|
@@ -362,7 +398,9 @@ nav .btn2 {
|
|
|
362
398
|
flex-shrink: 0;
|
|
363
399
|
|
|
364
400
|
display: flex;
|
|
401
|
+
/*
|
|
365
402
|
flex-direction: column;
|
|
403
|
+
*/
|
|
366
404
|
justify-content: center;
|
|
367
405
|
align-items: center;
|
|
368
406
|
}
|
|
@@ -389,6 +427,7 @@ body.dark #location {
|
|
|
389
427
|
display: flex;
|
|
390
428
|
align-items: stretch;
|
|
391
429
|
width: 100%;
|
|
430
|
+
flex-wrap: wrap;
|
|
392
431
|
}
|
|
393
432
|
body.dark .header-item.cursor.header-top {
|
|
394
433
|
background: none !important;
|
|
@@ -442,11 +481,28 @@ body.dark .loader-container {
|
|
|
442
481
|
#menu-mobile {
|
|
443
482
|
display: none;
|
|
444
483
|
}
|
|
484
|
+
.tabmenu .label {
|
|
485
|
+
padding: 10px;
|
|
486
|
+
border-bottom: 1px solid rgba(255,255,255,0.04);
|
|
487
|
+
text-transform: uppercase;
|
|
488
|
+
font-size: 12px;
|
|
489
|
+
font-weight: bold;
|
|
490
|
+
}
|
|
491
|
+
.disk-usage {
|
|
492
|
+
flex-grow: 1;
|
|
493
|
+
text-align: right;
|
|
494
|
+
font-weight: bold;
|
|
495
|
+
}
|
|
496
|
+
.disk-usage i {
|
|
497
|
+
margin-right: 5px;
|
|
498
|
+
font-size: 16px !important;
|
|
499
|
+
}
|
|
445
500
|
@media only screen and (max-width: 480px) {
|
|
446
501
|
nav .btn2 {
|
|
447
502
|
width: auto !important;
|
|
448
503
|
min-width: 40px;
|
|
449
504
|
border-right: none;
|
|
505
|
+
flex-direction: column;
|
|
450
506
|
}
|
|
451
507
|
.app-info {
|
|
452
508
|
display: flex;
|
|
@@ -467,15 +523,21 @@ body.dark .loader-container {
|
|
|
467
523
|
aside:not(.active) {
|
|
468
524
|
display: none;
|
|
469
525
|
}
|
|
526
|
+
.container {
|
|
527
|
+
display: none;
|
|
528
|
+
}
|
|
470
529
|
.container.active {
|
|
530
|
+
display: block;
|
|
471
531
|
position: absolute;
|
|
472
532
|
z-index: 10000000;
|
|
473
533
|
width: 100%;
|
|
474
534
|
height: 100%;
|
|
475
535
|
}
|
|
536
|
+
/*
|
|
476
537
|
.grid-btns {
|
|
477
538
|
display: none;
|
|
478
539
|
}
|
|
540
|
+
*/
|
|
479
541
|
#menu {
|
|
480
542
|
display: none;
|
|
481
543
|
}
|
|
@@ -487,6 +549,14 @@ body.dark .loader-container {
|
|
|
487
549
|
</head>
|
|
488
550
|
<body class='<%=theme%>' data-platform="<%=platform%>">
|
|
489
551
|
<aside class='active'>
|
|
552
|
+
<!--
|
|
553
|
+
<div class='footer'>
|
|
554
|
+
<button class='btn header-item' id='clone-tab'><i class='fa-regular fa-copy'></i></button>
|
|
555
|
+
<a class='btn header-item' id='open-browser' target="_blank" href="" features="browser"><i class="fa-solid fa-square-arrow-up-right"></i></a>
|
|
556
|
+
<button class='btn header-item' id='reload'><i class="fa-solid fa-rotate-right"></i></button>
|
|
557
|
+
<div id='new-tab' class='btn header-item'><i class="fa-solid fa-plus"></i></div>
|
|
558
|
+
</div>
|
|
559
|
+
-->
|
|
490
560
|
<div class='header-top header-item'>
|
|
491
561
|
<div class='app-info'>
|
|
492
562
|
<% if (config.icon) { %>
|
|
@@ -503,7 +573,13 @@ body.dark .loader-container {
|
|
|
503
573
|
<div class='tab'><i class="fa-solid fa-trash-can"></i> Delete</div>
|
|
504
574
|
</div>
|
|
505
575
|
<a target="<%=src%>" href="<%=src%>" class='btn header-item frame-link' data-index="0">
|
|
506
|
-
<div class='tab'><i class="fa-regular fa-folder-open"></i> Files
|
|
576
|
+
<div class='tab'><i class="fa-regular fa-folder-open"></i> Files <div class='disk-usage'></div></div>
|
|
577
|
+
</a>
|
|
578
|
+
<a target="/share/<%=name%>" href="/share/<%=name%>", class="btn header-item frame-link" data-index="1" data-mode="refresh">
|
|
579
|
+
<div class='tab'><i class="fa-solid fa-wifi"></i> Share</div>
|
|
580
|
+
</a>
|
|
581
|
+
<a target="/env/api/<%=name%>" href="/env/api/<%=name%>", class="btn header-item frame-link" data-index="1" data-mode="refresh">
|
|
582
|
+
<div class='tab'><i class="fa-solid fa-gear"></i> Configure</div>
|
|
507
583
|
</a>
|
|
508
584
|
</div>
|
|
509
585
|
<div class='m h menu' data-type='h'>
|
|
@@ -520,11 +596,23 @@ body.dark .loader-container {
|
|
|
520
596
|
</a>
|
|
521
597
|
<%})%>
|
|
522
598
|
</div>
|
|
523
|
-
<div id='new-tab' class='btn header-item'>
|
|
524
|
-
<i class="fa-solid fa-plus"></i>
|
|
525
|
-
</div>
|
|
526
599
|
<div class='flexible'></div>
|
|
527
600
|
<!--
|
|
601
|
+
<div class='tabmenu'>
|
|
602
|
+
<div id='new-tab' class='btn header-item'><div class='tab'><i class="fa-solid fa-plus"></i> New</div></div>
|
|
603
|
+
<button class='btn header-item' id='clone-tab'><div class='tab'><i class='fa-regular fa-copy'></i> Clone</div></button>
|
|
604
|
+
<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>
|
|
605
|
+
<button class='btn header-item' id='reload'><div class='tab'><i class="fa-solid fa-rotate-right"></i> Refresh</div></button>
|
|
606
|
+
</div>
|
|
607
|
+
-->
|
|
608
|
+
<div class='grid-btns'>
|
|
609
|
+
<a class='btn2' href="https://portal.pinokio.computer/" target="_blank"><div><i class="fa-solid fa-question"></i></div><div>Help</div></a>
|
|
610
|
+
<button class='btn2' id='genlog'><div><i class="fa-solid fa-laptop-code"></i></div><div>Debug</div></button>
|
|
611
|
+
<a id='downloadlogs' download class='hidden btn2' href="/pinokio/logs.zip"><div><i class="fa-solid fa-download"></i></div><div>Download logs</div></a>
|
|
612
|
+
<a class='btn2' href="/"><div><i class="fa-solid fa-house"></i></div><div>Home</div></a>
|
|
613
|
+
<button class='btn2' id='new-window' title='open a new window'><div><i class="fa-solid fa-plus"></i></div><div>Window</div></button>
|
|
614
|
+
</div>
|
|
615
|
+
<!--
|
|
528
616
|
<div class='grid-btns'>
|
|
529
617
|
<a class='btn2' href="/?mode=explore" id='explore'><div><i class="fa-solid fa-globe"></i></div><div>Discover</div></a>
|
|
530
618
|
<a class='btn2' id='report'><div><i class="fa-solid fa-bug"></i></div><div>Report Bug</div></a>
|
|
@@ -532,21 +620,10 @@ body.dark .loader-container {
|
|
|
532
620
|
<a class='btn2' href='https://twitter.com/cocktailpeanut' target="_blank"><div><i class="fa-brands fa-twitter"></i></div><div>Twitter</div></a>
|
|
533
621
|
</div>
|
|
534
622
|
-->
|
|
535
|
-
<div class='grid-btns'>
|
|
536
|
-
<button class='btn2' id='clone-tab'><div><i class='fa-regular fa-copy'></i></div><div>Clone</div></button>
|
|
537
|
-
<a class='btn2' id='open-browser' target="_blank" href="" features="browser"><div><i class="fa-solid fa-square-arrow-up-right"></i></div><div>Popout</div></a>
|
|
538
|
-
<button class='btn2' id='reload'><div><i class="fa-solid fa-rotate-right"></i></div><div>Refresh</div></button>
|
|
539
|
-
<a class='btn2' href="/?mode=help"><div><i class="fa-regular fa-face-smile"></i></div><div>Help</div></a>
|
|
540
|
-
</div>
|
|
541
|
-
<div class='footer'>
|
|
542
|
-
<a class='header-item logo' href="/"><i class="fa-solid fa-house"></i></a>
|
|
543
|
-
<a class='header-item logo' href="/?mode=settings"><i class="fa-solid fa-gear"></i></a>
|
|
544
|
-
<button id='new-window' title='open a new window'><i class="fa-solid fa-plus"></i></button>
|
|
545
|
-
</div>
|
|
546
623
|
</aside>
|
|
547
624
|
<div class='container'>
|
|
548
625
|
<nav>
|
|
549
|
-
<div class='
|
|
626
|
+
<div class='bar'>
|
|
550
627
|
<button class='btn2' id='menu-mobile'><i class="fa-solid fa-bars"></i></button>
|
|
551
628
|
<button class='btn2' id='menu'>
|
|
552
629
|
<img src="<%=rawpath%>/<%=config.icon%>?raw=true"/>
|
|
@@ -556,26 +633,16 @@ body.dark .loader-container {
|
|
|
556
633
|
<button class='btn2' id='back'><i class="fa-solid fa-chevron-left"></i></button>
|
|
557
634
|
<button class='btn2' id='forward'><i class="fa-solid fa-chevron-right"></i></button>
|
|
558
635
|
<% } %>
|
|
559
|
-
<!--
|
|
560
|
-
<button class='btn2' id='clone-tab'><i class='fa-regular fa-copy'></i> Clone</button>
|
|
561
|
-
<a class='btn2' id='open-browser' target="_blank" href="" features="browser"><i class="fa-solid fa-square-arrow-up-right"></i> Popout</a>
|
|
562
636
|
<button class='btn2' id='reload'><i class="fa-solid fa-rotate-right"></i> Refresh</button>
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
637
|
+
<% if (agent === "electron") { %>
|
|
638
|
+
<a class='btn2' id='open-browser' target="_blank" href="" features="browser"><i class="fa-solid fa-square-arrow-up-right"></i> Popout</a>
|
|
639
|
+
<% } else { %>
|
|
640
|
+
<a class='btn2' id='open-browser' target="_blank" href=""><i class="fa-solid fa-square-arrow-up-right"></i> Popout</a>
|
|
641
|
+
<% } %>
|
|
642
|
+
<button class='btn2' id='clone-tab'><i class='fa-regular fa-copy'></i> Clone</button>
|
|
643
|
+
<div id='new-tab' class='btn2'><i class="fa-solid fa-plus"></i> Tab</div>
|
|
567
644
|
<input type='url' id='location' readonly>
|
|
568
|
-
<!--
|
|
569
|
-
<div id='location'></div>
|
|
570
|
-
-->
|
|
571
645
|
</div>
|
|
572
|
-
<!--
|
|
573
|
-
<div class='flexible'></div>
|
|
574
|
-
<a class='btn2' href="/?mode=explore"><div><i class="fa-solid fa-globe"></i></div><div>Discover</div></a>
|
|
575
|
-
<a class='btn2' id='report'><div><i class="fa-solid fa-bug"></i></div><div>Report Bug</div></a>
|
|
576
|
-
<a class='btn2' href='https://discord.gg/TQdNwadtE4' target="_blank"><div><i class="fa-brands fa-discord"></i></div><div>Discord</div></a>
|
|
577
|
-
<a class='btn2' href='https://twitter.com/cocktailpeanut' target="_blank"><div><i class="fa-brands fa-twitter"></i></div><div>Twitter</div></a>
|
|
578
|
-
-->
|
|
579
646
|
</nav>
|
|
580
647
|
<main class='browserview'>
|
|
581
648
|
<% if (false) { %>
|
|
@@ -592,6 +659,7 @@ body.dark .loader-container {
|
|
|
592
659
|
<script>
|
|
593
660
|
let loaded = {}
|
|
594
661
|
let cursorIndex = 0;
|
|
662
|
+
const n = new N()
|
|
595
663
|
const getTarget = (href) => {
|
|
596
664
|
let u
|
|
597
665
|
if (href.startsWith("http")) {
|
|
@@ -624,9 +692,6 @@ const subUrlOf = (s, f) => {
|
|
|
624
692
|
if (!fullParsed.searchParams.has(key)) {
|
|
625
693
|
return false
|
|
626
694
|
}
|
|
627
|
-
console.log("key", key)
|
|
628
|
-
console.log("f", fullParsed.searchParams.get(key))
|
|
629
|
-
console.log("s", val)
|
|
630
695
|
if (fullParsed.searchParams.get(key) !== val) {
|
|
631
696
|
return false
|
|
632
697
|
}
|
|
@@ -639,7 +704,6 @@ const renderCursor = () => {
|
|
|
639
704
|
el.classList.remove("cursor")
|
|
640
705
|
})
|
|
641
706
|
const target = document.querySelector(".selectable[data-index='" + cursorIndex + "']")
|
|
642
|
-
console.log({ cursorIndex, target })
|
|
643
707
|
target.classList.add("cursor")
|
|
644
708
|
}
|
|
645
709
|
const nav = (type) => {
|
|
@@ -680,46 +744,53 @@ const nav = (type) => {
|
|
|
680
744
|
// }
|
|
681
745
|
}
|
|
682
746
|
const renderSelection = (e, force) => {
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
747
|
+
// if the menu has a default item, or if the url specifies a selection
|
|
748
|
+
let selection = document.querySelector("[data-default]")
|
|
749
|
+
if (selection || location.hash && location.hash.length > 0) {
|
|
750
|
+
let target
|
|
751
|
+
if (location.hash && location.hash.length > 0) {
|
|
752
|
+
// document.querySelector(".bar").classList.remove("hidden")
|
|
753
|
+
//let id = getTarget(location.hash.slice(1))
|
|
754
|
+
let id = location.hash.slice(1)
|
|
689
755
|
|
|
690
756
|
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
757
|
+
let selector
|
|
758
|
+
if (id.startsWith("@")) {
|
|
759
|
+
//selector = `aside [target='${id.slice(1)}']`
|
|
760
|
+
selector = `aside [target='${id}']`
|
|
761
|
+
} else {
|
|
762
|
+
let type = id[0]
|
|
763
|
+
let index = id.slice(1)
|
|
764
|
+
console.log({ type, index })
|
|
765
|
+
selector = `aside .${type} [data-index='${index}']`
|
|
766
|
+
}
|
|
700
767
|
|
|
701
768
|
|
|
702
|
-
|
|
703
|
-
// document.querySelectorAll(".frame-link").forEach((el) => {
|
|
704
|
-
// el.classList.remove("selected")
|
|
705
|
-
// })
|
|
769
|
+
// select the selected link
|
|
770
|
+
// document.querySelectorAll(".frame-link").forEach((el) => {
|
|
771
|
+
// el.classList.remove("selected")
|
|
772
|
+
// })
|
|
706
773
|
|
|
707
774
|
|
|
708
775
|
|
|
709
|
-
// const target = document.querySelector(`[target='${id}']`)
|
|
776
|
+
// const target = document.querySelector(`[target='${id}']`)
|
|
710
777
|
|
|
711
778
|
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
779
|
+
if (e) {
|
|
780
|
+
// If the renderSelection is triggered by an event, look for the frame-link that's triggering the event
|
|
781
|
+
if (e.target.classList.contains("frame-link")) {
|
|
782
|
+
target = e.target
|
|
783
|
+
} else {
|
|
784
|
+
target = e.target.closest(".frame-link")
|
|
785
|
+
}
|
|
717
786
|
} else {
|
|
718
|
-
target
|
|
787
|
+
// if not triggered by an event, look for the target from the location hash
|
|
788
|
+
target = document.querySelector(selector)
|
|
719
789
|
}
|
|
720
790
|
} else {
|
|
721
|
-
|
|
722
|
-
|
|
791
|
+
if (selection) {
|
|
792
|
+
target = selection
|
|
793
|
+
}
|
|
723
794
|
}
|
|
724
795
|
|
|
725
796
|
|
|
@@ -729,7 +800,6 @@ const renderSelection = (e, force) => {
|
|
|
729
800
|
//
|
|
730
801
|
// => select that tab and frame
|
|
731
802
|
|
|
732
|
-
console.log("target", target)
|
|
733
803
|
if (target) {
|
|
734
804
|
|
|
735
805
|
// display the menu button at the top
|
|
@@ -744,15 +814,13 @@ const renderSelection = (e, force) => {
|
|
|
744
814
|
}
|
|
745
815
|
|
|
746
816
|
if (target) {
|
|
747
|
-
console.log("# 3")
|
|
748
817
|
|
|
749
818
|
|
|
750
819
|
// Instantiate a frame with the selected target's href
|
|
751
820
|
let url = target.href
|
|
752
|
-
console.log("> url", url)
|
|
753
821
|
document.querySelector("#open-browser").href = url
|
|
754
822
|
document.querySelector("#clone-tab").setAttribute("data-href", url)
|
|
755
|
-
|
|
823
|
+
document.querySelector("#location").value = url
|
|
756
824
|
|
|
757
825
|
|
|
758
826
|
// select the selected target element (tab)
|
|
@@ -773,12 +841,12 @@ const renderSelection = (e, force) => {
|
|
|
773
841
|
let targetFrame;
|
|
774
842
|
if (target.closest(".h")) {
|
|
775
843
|
let hardFrames = document.querySelectorAll(".browserview iframe[name^='@']")
|
|
776
|
-
let port = new URL(target.href).port
|
|
844
|
+
let port = new URL(target.href).port || 80
|
|
777
845
|
for(let frame of hardFrames) {
|
|
778
846
|
console.log({ src: frame.src, href: target.href, target: target.target })
|
|
779
847
|
// Types of links in the tab
|
|
780
|
-
if (String(port) === "
|
|
781
|
-
// 1. running from
|
|
848
|
+
if (String(port) === "<%=port%>") {
|
|
849
|
+
// 1. running from <%=port%> => find a frame whose base URL matches the tab's base URL
|
|
782
850
|
// Pinokio links
|
|
783
851
|
let targetPath = new URL(target.href).pathname
|
|
784
852
|
let framePath = new URL(frame.src).pathname
|
|
@@ -805,7 +873,6 @@ const renderSelection = (e, force) => {
|
|
|
805
873
|
targetFrame = document.querySelector(`iframe[name='${target.target}']`)
|
|
806
874
|
}
|
|
807
875
|
|
|
808
|
-
|
|
809
876
|
/*
|
|
810
877
|
// Load the link in the frame
|
|
811
878
|
|
|
@@ -840,7 +907,6 @@ const renderSelection = (e, force) => {
|
|
|
840
907
|
e.preventDefault()
|
|
841
908
|
e.stopPropagation()
|
|
842
909
|
let sub = subUrlOf(target.href, targetFrame.src)
|
|
843
|
-
console.log("issub", sub)
|
|
844
910
|
if (!sub) {
|
|
845
911
|
targetFrame.src = target.href
|
|
846
912
|
}
|
|
@@ -871,13 +937,14 @@ const renderSelection = (e, force) => {
|
|
|
871
937
|
}
|
|
872
938
|
} else {
|
|
873
939
|
if (force) {
|
|
874
|
-
console.log("# 7")
|
|
875
940
|
targetFrame.src = target.href
|
|
876
941
|
}
|
|
877
942
|
}
|
|
943
|
+
targetFrame.contentWindow.postMessage({
|
|
944
|
+
action: "foreground"
|
|
945
|
+
}, "*")
|
|
878
946
|
}
|
|
879
947
|
} else {
|
|
880
|
-
console.log("# 12")
|
|
881
948
|
let frame = document.createElement("iframe")
|
|
882
949
|
frame.name = target.target
|
|
883
950
|
frame.src = target.href
|
|
@@ -977,10 +1044,13 @@ const renderSelection = (e, force) => {
|
|
|
977
1044
|
console.log("# 14")
|
|
978
1045
|
document.querySelector(".container").classList.remove("active")
|
|
979
1046
|
document.querySelector("aside").classList.add("active")
|
|
1047
|
+
|
|
980
1048
|
}
|
|
981
1049
|
}
|
|
982
1050
|
console.log("loaded before", loaded)
|
|
1051
|
+
<% if (type === "run" && env.PINOKIO_SCRIPT_DEFAULT && env.PINOKIO_SCRIPT_DEFAULT.toString().toLowerCase() === "true") { %>
|
|
983
1052
|
renderSelection()
|
|
1053
|
+
<% } %>
|
|
984
1054
|
//renderCursor()
|
|
985
1055
|
console.log("loaded after", loaded)
|
|
986
1056
|
//Reporter()
|
|
@@ -1103,7 +1173,7 @@ const addTab = async (url) => {
|
|
|
1103
1173
|
if (document.querySelector("#menu-mobile")) {
|
|
1104
1174
|
document.querySelector("#menu-mobile").addEventListener("click", async (e) => {
|
|
1105
1175
|
location.hash = ""
|
|
1106
|
-
refresh()
|
|
1176
|
+
refresh(false, { nodelay: true })
|
|
1107
1177
|
})
|
|
1108
1178
|
}
|
|
1109
1179
|
if (document.querySelector("#menu")) {
|
|
@@ -1161,7 +1231,7 @@ document.querySelector("aside").addEventListener("click", async (e) => {
|
|
|
1161
1231
|
let target
|
|
1162
1232
|
|
|
1163
1233
|
|
|
1164
|
-
// delete
|
|
1234
|
+
// 1. handle delete
|
|
1165
1235
|
if (e.target.classList.contains("del")) {
|
|
1166
1236
|
target = e.target
|
|
1167
1237
|
} else {
|
|
@@ -1184,144 +1254,251 @@ document.querySelector("aside").addEventListener("click", async (e) => {
|
|
|
1184
1254
|
el.remove()
|
|
1185
1255
|
// update tabs
|
|
1186
1256
|
await syncTabs()
|
|
1257
|
+
return
|
|
1258
|
+
}
|
|
1187
1259
|
|
|
1188
|
-
} else {
|
|
1189
|
-
// Select
|
|
1190
|
-
if (e.target.classList.contains("frame-link")) {
|
|
1191
|
-
target = e.target
|
|
1192
|
-
} else {
|
|
1193
|
-
target = e.target.closest(".frame-link")
|
|
1194
|
-
}
|
|
1195
1260
|
|
|
1261
|
+
// 2. handle shudown
|
|
1262
|
+
if (e.target.classList.contains("shutdown")) {
|
|
1263
|
+
target = e.target
|
|
1264
|
+
} else {
|
|
1265
|
+
target = e.target.closest(".shutdown")
|
|
1266
|
+
}
|
|
1267
|
+
if (target) {
|
|
1268
|
+
e.preventDefault()
|
|
1269
|
+
e.stopPropagation()
|
|
1270
|
+
let link = target.closest("[href]")
|
|
1271
|
+
let src = new URL(link.href).pathname
|
|
1272
|
+
target.querySelector("i.fa-square").className = "fa-solid fa-check"
|
|
1273
|
+
n.Noty({
|
|
1274
|
+
text: `stopping ${src}`,
|
|
1275
|
+
silent: true,
|
|
1276
|
+
timeout: 2000
|
|
1277
|
+
})
|
|
1278
|
+
console.log("src", src)
|
|
1196
1279
|
|
|
1280
|
+
let socket = new Socket()
|
|
1281
|
+
socket.run({
|
|
1282
|
+
method: "kernel.api.stop",
|
|
1283
|
+
params: {
|
|
1284
|
+
uri: "~" + src
|
|
1285
|
+
}
|
|
1286
|
+
}, (packet) => {
|
|
1287
|
+
if (packet.type === "result") {
|
|
1288
|
+
socket.close()
|
|
1289
|
+
n.Noty({
|
|
1290
|
+
timeout: 2000,
|
|
1291
|
+
text: `stopped`,
|
|
1292
|
+
silent: true
|
|
1293
|
+
})
|
|
1294
|
+
refresh(true)
|
|
1295
|
+
}
|
|
1296
|
+
})
|
|
1197
1297
|
|
|
1198
|
-
|
|
1298
|
+
return
|
|
1299
|
+
}
|
|
1199
1300
|
|
|
1200
|
-
// if data-confirm exists, ask for confirmation
|
|
1201
|
-
// if not, then just go forward
|
|
1202
|
-
let confirmText = target.getAttribute("data-confirm")
|
|
1203
|
-
if (confirmText && confirmText.length > 0) {
|
|
1204
|
-
const confirmed = confirm(confirmText)
|
|
1205
|
-
console.log('confirmed', confirmed)
|
|
1206
|
-
if (!confirmed) {
|
|
1207
|
-
e.preventDefault()
|
|
1208
|
-
e.stopPropagation()
|
|
1209
|
-
return
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
1301
|
|
|
1213
|
-
if (target.getAttribute("data-action")) {
|
|
1214
|
-
let actionStr = target.getAttribute("data-action")
|
|
1215
|
-
let action = JSON.parse(actionStr)
|
|
1216
|
-
console.log("action", action)
|
|
1217
|
-
if (action.method === "stop" && action.uri) {
|
|
1218
|
-
let socket = new Socket()
|
|
1219
|
-
socket.run({
|
|
1220
|
-
method: "kernel.api.stop",
|
|
1221
|
-
params: {
|
|
1222
|
-
uri: action.uri//"~" + location.pathname
|
|
1223
|
-
}
|
|
1224
|
-
}, (packet) => {
|
|
1225
|
-
console.log("packet", packet)
|
|
1226
|
-
if (packet.type === "result") {
|
|
1227
|
-
socket.close()
|
|
1228
|
-
// location.href = location.href
|
|
1229
|
-
}
|
|
1230
|
-
})
|
|
1231
|
-
}
|
|
1232
|
-
} else if (target.target === "_blank") {
|
|
1233
|
-
// nothing
|
|
1234
|
-
} else {
|
|
1235
|
-
if (target.classList.contains("reveal")) {
|
|
1236
|
-
// nested menu
|
|
1237
|
-
target.closest(".nested-menu").querySelector(".submenu").classList.toggle("hidden")
|
|
1238
|
-
e.preventDefault()
|
|
1239
|
-
e.stopPropagation()
|
|
1240
|
-
} else {
|
|
1241
|
-
//location.hash = target.target
|
|
1242
1302
|
|
|
1303
|
+
// 3. handle select
|
|
1304
|
+
if (e.target.classList.contains("frame-link")) {
|
|
1305
|
+
target = e.target
|
|
1306
|
+
} else {
|
|
1307
|
+
target = e.target.closest(".frame-link")
|
|
1308
|
+
}
|
|
1243
1309
|
|
|
1244
|
-
// let id = getTarget(target.getAttribute("href"))
|
|
1245
|
-
// console.log("ID", id, target.href)
|
|
1246
|
-
// location.hash = id
|
|
1247
1310
|
|
|
1248
|
-
//location.hash = target.getAttribute("href")
|
|
1249
1311
|
|
|
1250
|
-
|
|
1251
|
-
location.hash = target.target
|
|
1252
|
-
} else {
|
|
1253
|
-
let index = target.getAttribute("data-index")
|
|
1254
|
-
let type = target.closest(".m").getAttribute("data-type")
|
|
1312
|
+
if (target) {
|
|
1255
1313
|
|
|
1314
|
+
// if data-confirm exists, ask for confirmation
|
|
1315
|
+
// if not, then just go forward
|
|
1316
|
+
let confirmText = target.getAttribute("data-confirm")
|
|
1317
|
+
if (confirmText && confirmText.length > 0) {
|
|
1318
|
+
const confirmed = confirm(confirmText)
|
|
1319
|
+
if (!confirmed) {
|
|
1320
|
+
e.preventDefault()
|
|
1321
|
+
e.stopPropagation()
|
|
1322
|
+
return
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1256
1325
|
|
|
1257
|
-
|
|
1326
|
+
if (target.getAttribute("data-action")) {
|
|
1327
|
+
let actionStr = target.getAttribute("data-action")
|
|
1328
|
+
let action = JSON.parse(actionStr)
|
|
1329
|
+
console.log("action", action)
|
|
1330
|
+
if (action.method === "stop" && action.uri) {
|
|
1331
|
+
let socket = new Socket()
|
|
1332
|
+
socket.run({
|
|
1333
|
+
method: "kernel.api.stop",
|
|
1334
|
+
params: {
|
|
1335
|
+
uri: action.uri//"~" + location.pathname
|
|
1258
1336
|
}
|
|
1337
|
+
}, (packet) => {
|
|
1338
|
+
if (packet.type === "result") {
|
|
1339
|
+
socket.close()
|
|
1340
|
+
// location.href = location.href
|
|
1341
|
+
}
|
|
1342
|
+
})
|
|
1343
|
+
}
|
|
1344
|
+
} else if (target.getAttribute("data-filepath")) {
|
|
1345
|
+
return
|
|
1346
|
+
} else if (target.target === "_blank") {
|
|
1347
|
+
// nothing
|
|
1348
|
+
} else {
|
|
1349
|
+
if (target.classList.contains("reveal")) {
|
|
1350
|
+
// nested menu
|
|
1351
|
+
target.closest(".nested-menu").querySelector(".submenu").classList.toggle("hidden")
|
|
1352
|
+
e.preventDefault()
|
|
1353
|
+
e.stopPropagation()
|
|
1354
|
+
} else {
|
|
1355
|
+
//location.hash = target.target
|
|
1259
1356
|
|
|
1260
|
-
document.querySelectorAll(".frame-link").forEach((el) => {
|
|
1261
|
-
el.classList.remove("selected")
|
|
1262
|
-
})
|
|
1263
|
-
target.classList.add("selected")
|
|
1264
1357
|
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1358
|
+
// let id = getTarget(target.getAttribute("href"))
|
|
1359
|
+
// console.log("ID", id, target.href)
|
|
1360
|
+
// location.hash = id
|
|
1361
|
+
|
|
1362
|
+
//location.hash = target.getAttribute("href")
|
|
1363
|
+
|
|
1364
|
+
if (target.closest(".h")) {
|
|
1365
|
+
location.hash = target.target
|
|
1366
|
+
} else {
|
|
1367
|
+
let index = target.getAttribute("data-index")
|
|
1368
|
+
let type = target.closest(".m").getAttribute("data-type")
|
|
1268
1369
|
|
|
1269
1370
|
|
|
1371
|
+
location.hash = type + index
|
|
1372
|
+
}
|
|
1270
1373
|
|
|
1374
|
+
document.querySelectorAll(".frame-link").forEach((el) => {
|
|
1375
|
+
el.classList.remove("selected")
|
|
1376
|
+
})
|
|
1377
|
+
target.classList.add("selected")
|
|
1271
1378
|
|
|
1379
|
+
renderSelection(e)
|
|
1380
|
+
}
|
|
1272
1381
|
}
|
|
1273
1382
|
}
|
|
1274
1383
|
|
|
1275
1384
|
|
|
1276
1385
|
|
|
1277
1386
|
})
|
|
1278
|
-
const
|
|
1279
|
-
console.log("REFRESH")
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1387
|
+
const refresh_du = () => {
|
|
1388
|
+
console.log("REFRESH DU")
|
|
1389
|
+
fetch("/du/<%=name%>").then((res) => {
|
|
1390
|
+
return res.json()
|
|
1391
|
+
}).then((res) => {
|
|
1392
|
+
let val
|
|
1393
|
+
//let k = 1024
|
|
1394
|
+
let k = 1000
|
|
1395
|
+
if (res.du > k * k * k) {
|
|
1396
|
+
// GB
|
|
1397
|
+
val = `${Math.floor(res.du/k/k/k * 100) / 100} GB`
|
|
1398
|
+
} else if (res.du > k * k) {
|
|
1399
|
+
// MB
|
|
1400
|
+
val = `${Math.floor(res.du/k/k * 100) / 100} MB`
|
|
1401
|
+
} else {
|
|
1402
|
+
// KB
|
|
1403
|
+
val = `${Math.floor(res.du/k * 100) / 100} KB`
|
|
1404
|
+
}
|
|
1405
|
+
console.log("DU VAL", val)
|
|
1406
|
+
//document.querySelector(".disk-usage").innerHTML = `<i class="fa-regular fa-hard-drive"></i> ${val}`
|
|
1407
|
+
document.querySelector(".disk-usage").innerHTML = val
|
|
1284
1408
|
})
|
|
1409
|
+
}
|
|
1410
|
+
const refresh = async (silent, options) => {
|
|
1411
|
+
if (options && options.nodelay) {
|
|
1412
|
+
} else {
|
|
1413
|
+
await new Promise((resolve, reject) => {
|
|
1414
|
+
setTimeout(() => {
|
|
1415
|
+
resolve()
|
|
1416
|
+
}, 1000)
|
|
1417
|
+
})
|
|
1418
|
+
}
|
|
1285
1419
|
const html = await fetch("<%=sidebar%>").then((res) => {
|
|
1286
1420
|
return res.text()
|
|
1287
1421
|
})
|
|
1288
1422
|
document.querySelector(".menu").innerHTML = html
|
|
1289
1423
|
location.hash = ""
|
|
1290
|
-
|
|
1424
|
+
|
|
1425
|
+
// render the selected frame only if not silent
|
|
1426
|
+
if (silent) {
|
|
1427
|
+
} else {
|
|
1428
|
+
if (options && options.nodelay) {
|
|
1429
|
+
} else {
|
|
1430
|
+
// await new Promise((resolve, reject) => {
|
|
1431
|
+
// setTimeout(() => {
|
|
1432
|
+
// resolve()
|
|
1433
|
+
// }, 500)
|
|
1434
|
+
// })
|
|
1435
|
+
}
|
|
1436
|
+
renderSelection()
|
|
1437
|
+
}
|
|
1438
|
+
refresh_du()
|
|
1439
|
+
}
|
|
1440
|
+
if (document.querySelector("#genlog")) {
|
|
1441
|
+
document.querySelector("#genlog").addEventListener("click", (e) => {
|
|
1442
|
+
e.preventDefault()
|
|
1443
|
+
e.stopPropagation()
|
|
1444
|
+
e.target.innerHTML = '<i class="fa-solid fa-circle-notch fa-spin"></i>'
|
|
1445
|
+
fetch("/pinokio/log", {
|
|
1446
|
+
method: "post",
|
|
1447
|
+
}).then((res) => {
|
|
1448
|
+
let btn = document.querySelector("#genlog")
|
|
1449
|
+
let btn2 = document.querySelector("#downloadlogs")
|
|
1450
|
+
btn2.classList.remove("hidden")
|
|
1451
|
+
btn.classList.add("hidden")
|
|
1452
|
+
btn.innerHTML = '<i class="fa-solid fa-circle-check"></i> Generated!'
|
|
1453
|
+
//btn.classList.add("hidden")
|
|
1454
|
+
})
|
|
1455
|
+
})
|
|
1291
1456
|
}
|
|
1292
1457
|
window.addEventListener('message', (event) => {
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1458
|
+
|
|
1459
|
+
// only process the event it's coming from pinokio
|
|
1460
|
+
let origin = event.origin
|
|
1461
|
+
if (origin) {
|
|
1462
|
+
let port = new URL(origin).port || 80
|
|
1463
|
+
console.log("port", port)
|
|
1464
|
+
if (String(port) === "<%=port%>") {
|
|
1465
|
+
console.log("Message received from the child: ", event); // Message received from child
|
|
1466
|
+
if (event.data) {
|
|
1467
|
+
if (event.data.action) {
|
|
1468
|
+
if (event.data.action.type === "newtab") {
|
|
1469
|
+
console.log("create tab", event.data.action.url)
|
|
1470
|
+
addTab(event.data.action.url)
|
|
1471
|
+
} else if (event.data.action.type === "title") {
|
|
1472
|
+
console.log("title", event.data)
|
|
1473
|
+
} else if (event.data.action.type === "location") {
|
|
1474
|
+
let url = event.data.action.url
|
|
1475
|
+
console.log({ action: event.data.action })
|
|
1476
|
+
document.querySelector("#open-browser").href = url
|
|
1477
|
+
//document.querySelector("#location").innerHTML = url
|
|
1478
|
+
document.querySelector("#location").value = url
|
|
1479
|
+
}
|
|
1480
|
+
} else if (event.data.type) {
|
|
1481
|
+
let asideHidden = (window.getComputedStyle(document.querySelector("aside")).display === "none")
|
|
1482
|
+
console.log("asideHidden", asideHidden)
|
|
1483
|
+
if (!asideHidden) {
|
|
1484
|
+
// refresh only if aside
|
|
1485
|
+
|
|
1486
|
+
if (event.data.type === 'disconnect') {
|
|
1487
|
+
refresh()
|
|
1488
|
+
} else {
|
|
1489
|
+
refresh()
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1318
1492
|
}
|
|
1493
|
+
} else {
|
|
1494
|
+
refresh()
|
|
1319
1495
|
}
|
|
1320
1496
|
}
|
|
1321
|
-
} else {
|
|
1322
|
-
refresh()
|
|
1323
1497
|
}
|
|
1498
|
+
|
|
1499
|
+
|
|
1324
1500
|
});
|
|
1501
|
+
refresh_du()
|
|
1325
1502
|
/*
|
|
1326
1503
|
document.addEventListener("keydown", (e) => {
|
|
1327
1504
|
let size = document.querySelectorAll(".selectable").length
|