pinokiod 1.3.37 → 1.3.39

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.
@@ -0,0 +1,60 @@
1
+ const { yellow, green, blue } = require('kleur');
2
+ const QRCode = require('qrcode');
3
+ class C {
4
+ async tunnel (req, ondata, kernel) {
5
+ /*
6
+ {
7
+ "method": "cloundflare.tunnel",
8
+ "params": {
9
+ "uri": "{{local.url}}"
10
+ }
11
+ }
12
+
13
+ => cloudflared tunnel --url http://localhost:8080
14
+ */
15
+ const message = `cloudflared tunnel --url ${req.params.uri}`
16
+ let params = {
17
+ id: message,
18
+ message
19
+ }
20
+ if (req.client) {
21
+ params.rows = req.client.rows
22
+ params.cols = req.client.cols
23
+ }
24
+ let options = {}
25
+ if (req.cwd) options.cwd = req.cwd
26
+ if (req.parent && req.parent.path) options.group = req.parent.path
27
+ console.log("shells before", kernel.shell.shells)
28
+ let pattern = /(https:.+?trycloudflare\.com)/
29
+ let cloudflare_url = await new Promise((resolve, reject) => {
30
+ kernel.shell.start(params, options, (e) => {
31
+ ondata(e)
32
+ let test = pattern.exec(e.cleaned)
33
+ if (test && test.length > 0) {
34
+ resolve(test[1])
35
+ }
36
+ })
37
+ })
38
+ console.log("cloudflare_url", cloudflare_url)
39
+
40
+ ondata({ raw: yellow("\r\n## Scan the QR code to open in any device\r\n\r\n") })
41
+ ondata({ raw: blue(`${cloudflare_url}\r\n\r\n`) })
42
+
43
+ await new Promise((resolve, reject) => {
44
+ QRCode.toString(cloudflare_url, {
45
+ type: "terminal"
46
+ }, function(err, data) {
47
+ ondata({ raw: green(data).replaceAll("\n", "\r\n") })
48
+ ondata({ raw: "\r\n" })
49
+ setTimeout(() => {
50
+ resolve()
51
+ }, 2000)
52
+ });
53
+ })
54
+
55
+ return { uri: cloudflare_url }
56
+ }
57
+ async stop (req, ondata, kernel) {
58
+ }
59
+ }
60
+ module.exports = C
@@ -0,0 +1,25 @@
1
+ const path = require('path')
2
+ class Web {
3
+ /*
4
+ {
5
+ method: "web.expose",
6
+ params: {
7
+ uri: "{{local.uri}}"
8
+ }
9
+ }
10
+ */
11
+ async expose(req, ondata, kernel) {
12
+ let parent_path = req.parent.path
13
+ let userdir = path.resolve(kernel.homedir, "api")
14
+ let rel_path= path.relative(userdir, parent_path)
15
+ let app = rel_path.split(path.sep)[0]
16
+ let uri = req.params.uri
17
+ console.log({ userdir, rel_path, app })
18
+ ondata({
19
+ raw: `\r\n[Exposing Web URL] /app/${app} => ${req.params.uri}\r\n`
20
+ })
21
+ kernel.exposed[app] = req.params.uri
22
+ console.log("kernel.exposed", kernel.exposed)
23
+ }
24
+ }
25
+ module.exports = Web
@@ -0,0 +1,54 @@
1
+ const fs = require('fs')
2
+ class Cloudflared {
3
+ async uninstall(req, ondata) {
4
+ ondata({ raw: "cleaning up\r\n" })
5
+ let bin = this.kernel.bin
6
+ if (bin.platform === "darwin") {
7
+ await this.kernel.bin.exec({
8
+ message: "brew uninstall cloudflared",
9
+ }, ondata)
10
+ } else if (bin.platform === "win32") {
11
+ const folder = this.kernel.bin.path("cloudflared.exe")
12
+ await fs.promises.rm(folder).catch((e) => {
13
+ })
14
+ } else {
15
+ const folder = this.kernel.bin.path("cloudflared")
16
+ await fs.promises.rm(folder).catch((e) => {
17
+ })
18
+ }
19
+ ondata({ raw: "finished cleaning up\r\n" })
20
+ }
21
+ async install(req, ondata) {
22
+ let bin = this.kernel.bin
23
+ if (bin.platform === "darwin") {
24
+ await this.kernel.bin.exec({
25
+ message: "brew install cloudflared",
26
+ }, ondata)
27
+ } else if (bin.platform === "win32") {
28
+ const url = "https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-windows-amd64.exe"
29
+ const dest = "cloudflared.exe"
30
+ await this.kernel.bin.download(url, dest, ondata)
31
+ } else {
32
+ let url
33
+ if (bin.arch === "x64") {
34
+ url = "https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64"
35
+ } else if (bin.arch === "arm64") {
36
+ url = "https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-arm64"
37
+ }
38
+ const dest = "cloudflared"
39
+ await this.kernel.bin.download(url, dest, ondata)
40
+ }
41
+ }
42
+ async installed() {
43
+ if (this.kernel.platform === 'win32') {
44
+ let e = await this.kernel.bin.exists("cloudflared.exe")
45
+ return e
46
+ } else if (this.kernel.platform === "darwin") {
47
+ return this.kernel.bin.installed.brew.has("cloudflared")
48
+ } else {
49
+ let e = await this.kernel.bin.exists("cloudflared")
50
+ return e
51
+ }
52
+ }
53
+ }
54
+ module.exports = Cloudflared
package/kernel/index.js CHANGED
@@ -39,6 +39,7 @@ class Kernel {
39
39
  this.platform = os.platform()
40
40
  this.key = new Key()
41
41
  this.jsdom = jsdom
42
+ this.exposed = {}
42
43
  }
43
44
  resumeprocess(uri) {
44
45
  let proc = this.procs[uri]
package/kernel/shell.js CHANGED
@@ -146,6 +146,9 @@ class Shell {
146
146
  this.env[PATH_KEY]
147
147
  ].join(':');
148
148
  }
149
+
150
+ this.env[PATH_KEY] = this.env[PATH_KEY] + path.delimiter + path.resolve(this.kernel.homedir, 'bin')
151
+
149
152
  // custom env was passed in
150
153
 
151
154
  // override cache folders if cache is specified
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "1.3.37",
3
+ "version": "1.3.39",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -37,6 +37,7 @@
37
37
  "jsdom": "^24.0.0",
38
38
  "jsonpath-plus": "^7.2.0",
39
39
  "key-store": "^1.2.0",
40
+ "kleur": "^4.1.5",
40
41
  "lodash": "^4.17.21",
41
42
  "lproxy": "^0.0.9",
42
43
  "marked": "^5.0.1",
package/script/index.js CHANGED
@@ -35,8 +35,8 @@ class Store {
35
35
  }
36
36
  }
37
37
  const server = new Server({
38
- //port: 42000,
39
- port: 80,
38
+ port: 42000,
39
+ //port: 80,
40
40
  agent: "web",
41
41
  store: new Store()
42
42
  })
package/server/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  const express = require('express');
2
+ const portfinder = require('portfinder');
2
3
  const proxy = require('express-http-proxy-cp');
3
4
  const sudo = require("sudo-prompt-programfiles-x86");
4
5
  const compressing = require('compressing');
@@ -356,6 +357,8 @@ class Server {
356
357
  args: "-c conda-forge"
357
358
  }, {
358
359
  name: "py"
360
+ }, {
361
+ name: "cloudflared"
359
362
  }]
360
363
  let platform = os.platform()
361
364
  if (platform === "win32") {
@@ -419,6 +422,10 @@ class Server {
419
422
  ],
420
423
  val: this.kernel.homedir,
421
424
  placeholder: "Enter the absolute path to use as your Pinokio home folder (D:\\pinokio, /Users/alice/pinokiofs, etc.)"
425
+ // }, {
426
+ // key: "drive",
427
+ // val: path.resolve(this.kernel.homedir, "drive"),
428
+ // placeholder: "Pinokio virtual drives folder"
422
429
  }, {
423
430
  key: "theme",
424
431
  val: this.theme,
@@ -433,6 +440,7 @@ class Server {
433
440
  }
434
441
  }
435
442
  res.render("settings", {
443
+ platform,
436
444
  version: this.version,
437
445
  logo: this.logo,
438
446
  theme: this.theme,
@@ -610,6 +618,8 @@ class Server {
610
618
  args: "-c conda-forge"
611
619
  }, {
612
620
  name: "py"
621
+ }, {
622
+ name: "cloudflared"
613
623
  }]
614
624
  let platform = os.platform()
615
625
  if (platform === "win32") {
@@ -1653,6 +1663,7 @@ class Server {
1653
1663
  async setConfig(config) {
1654
1664
  let home = this.kernel.store.get("home")
1655
1665
  let theme = this.kernel.store.get("theme")
1666
+ // let drive = this.kernel.store.get("drive")
1656
1667
 
1657
1668
  // 1. Handle THEME
1658
1669
  if (config.theme) {
@@ -1682,6 +1693,28 @@ class Server {
1682
1693
  }
1683
1694
 
1684
1695
  }
1696
+ // // 3. Handle Drive
1697
+ // if (config.drive) {
1698
+ // // if the home is different from the existing home, go forward
1699
+ // if (config.drive !== drive) {
1700
+ // const basename = path.basename(config.drive)
1701
+ // // check for invalid path
1702
+ // let isValidPath = (basename !== '' && basename !== config.drive)
1703
+ // if (!isValidPath) {
1704
+ // throw new Error("Invalid path: " + config.home)
1705
+ // }
1706
+ //
1707
+ // // check if the destination already exists => throw error
1708
+ // let exists = await fse.pathExists(config.drive)
1709
+ // if (exists) {
1710
+ // throw new Error(`The path ${config.drive} already exists. Please remove the folder and retry`)
1711
+ // }
1712
+ //
1713
+ // this.kernel.store.set("drive", config.drive)
1714
+ // }
1715
+ //
1716
+ // }
1717
+
1685
1718
 
1686
1719
  home = this.kernel.store.get("home")
1687
1720
  theme = this.kernel.store.get("theme")
@@ -1743,6 +1776,10 @@ class Server {
1743
1776
  await this.httpTerminator.terminate();
1744
1777
  } catch (e) {
1745
1778
  }
1779
+ // try {
1780
+ // await this.exposeTerminator.terminate();
1781
+ // } catch (e) {
1782
+ // }
1746
1783
  }
1747
1784
  console.log("** AA")
1748
1785
 
@@ -1819,10 +1856,10 @@ class Server {
1819
1856
  this.app.set("views", path.resolve(__dirname, "views"))
1820
1857
  this.app.use(express.json());
1821
1858
  this.app.use(express.urlencoded({ extended: true }));
1822
-
1823
1859
  this.app.use(cookieParser());
1824
1860
  this.app.use(session({secret: "secret" }))
1825
1861
 
1862
+
1826
1863
  //let home = this.kernel.homedir
1827
1864
  let home = this.kernel.store.get("home")
1828
1865
  this.app.get("/", async (req, res) => {
@@ -1867,6 +1904,11 @@ class Server {
1867
1904
  ],
1868
1905
  val: this.kernel.homedir ? this.kernel.homedir : _home,
1869
1906
  placeholder: "Enter the absolute path to use as your Pinokio home folder (D:\\pinokio, /Users/alice/pinokiofs, etc.)"
1907
+ // }, {
1908
+ // key: "drive",
1909
+ // val: path.resolve(this.kernel.homedir, "drive"),
1910
+ // description: ["Virtual drive folder (Don't change it unless you know what you're doing)"],
1911
+ // placeholder: "Pinokio virtual drives folder"
1870
1912
  }, {
1871
1913
  key: "theme",
1872
1914
  val: this.theme,
@@ -1881,6 +1923,7 @@ class Server {
1881
1923
  }
1882
1924
  }
1883
1925
  res.render("settings", {
1926
+ platform,
1884
1927
  version: this.version,
1885
1928
  logo: this.logo,
1886
1929
  theme: this.theme,
@@ -1950,76 +1993,6 @@ class Server {
1950
1993
 
1951
1994
 
1952
1995
 
1953
- // /*
1954
- //
1955
- // Requirements
1956
- //
1957
- // 1. When entering /app/:name, it should open the app's page if it's running. If not running, start the app, and open the app's page at the end
1958
- //
1959
- // /app/:name
1960
- //
1961
- // - check the /api/:name folder
1962
- // - if it exists:
1963
- // - check pinokio.js for start attribute
1964
- // - if start exists,
1965
- // - if it doesn't exist:
1966
- //
1967
- // 2. how about when i want to use the tab view?
1968
- //
1969
- //
1970
- // what if the browser view stays, but just add a "default" attribute for tabs, and select that by default
1971
- //
1972
- //
1973
- // what if every script after starting, checks for local.url, and if it exists,
1974
- //
1975
- // */
1976
- // this.app.get("/app/:name", async (req, res) => {
1977
- //
1978
- // // 1. take req.params.name and resolve the folder name
1979
- // let name = req.params.name
1980
- // let app_path = this.kernel.path("api", name, "pinokio.js")
1981
- // // 2. open pinokio.js to check the start attribute
1982
- // let config = (await this.kernel.loader.load(app_path)).resolved
1983
- // if (config && config.start) {
1984
- // if (typeof config.start === "function") {
1985
- // if (config.start.constructor.name === "AsyncFunction") {
1986
- // config.start = await config.start(this.kernel)
1987
- // } else {
1988
- // config.start = config.start(this.kernel)
1989
- // }
1990
- // }
1991
- // // 3. check if the start script is running
1992
- // let startScriptPath = this.kernel.path("api", name, config.start)
1993
- // if (this.kernel.running(startScriptPath)) {
1994
- // // 4.a. if running, route to the local.url for the start script
1995
- // let local = this.kernel.local(startScriptPath)
1996
- // if (local && local.url) {
1997
- // // if local.url exists, display that
1998
- // res.redirect(local.url)
1999
- // } else {
2000
- // // if local.url doesn't exist, display the app page
2001
- // res.redirect(`http://localhost:${this.port}/pinokio/browser/${req.params.name}`)
2002
- // }
2003
- // } else {
2004
- // // 4.b. if not running, start the script and render the loading screen
2005
- // // => the loading screen will automatically reload after the script has started
2006
- // if (typeof config.start === 'object') {
2007
- // let url = config.start.url
2008
- // let params = config.start.params
2009
- // let queryStr = new URLSearchParams(params).toString()
2010
- // let u = `http://localhost:${this.port}/pinokio/launch/${req.params.name}/${url}?${queryStr}`
2011
- // console.log("u1", u)
2012
- // res.redirect(u)
2013
- // } else {
2014
- // let url = config.start
2015
- // let u = `http://localhost:${this.port}/pinokio/launch/${req.params.name}/${url}`
2016
- // //let u = `/api/${req.params.name}/${url}`
2017
- // console.log("u2", u)
2018
- // res.redirect(u)
2019
- // }
2020
- // }
2021
- // }
2022
- // })
2023
1996
 
2024
1997
  this.app.get("/script/:name", (req, res) => {
2025
1998
  if (req.params.name === "start") {
@@ -2561,6 +2534,48 @@ class Server {
2561
2534
  server: this.listening
2562
2535
  });
2563
2536
  })
2537
+
2538
+
2539
+
2540
+ // this.expose_app = express();
2541
+ // this.expose_app.use(cors({
2542
+ // origin: '*'
2543
+ // }));
2544
+ // this.expose_app.use('/', proxy(async (req) => {
2545
+ // console.log("req.url", req.url)
2546
+ // let tokens = req.url.split("/")
2547
+ // console.log({ tokens })
2548
+ // if (tokens.length >=2 ) {
2549
+ // let app = tokens[1]
2550
+ // console.log({ app })
2551
+ // console.log("resolved = ", this.kernel.exposed[app])
2552
+ // return this.kernel.exposed[app]
2553
+ // }
2554
+ // }, {
2555
+ //// proxyReqPathResolver: (req) => {
2556
+ //// console.log("proxyReqPathResolver", req.url)
2557
+ //// let chunks = req.url.split("/")
2558
+ //// let transformed
2559
+ //// if (chunks.length > 3) {
2560
+ //// transformed = "/" + chunks.slice(3).join("/")
2561
+ //// } else {
2562
+ //// transformed = "/"
2563
+ //// }
2564
+ //// console.log({ chunks, transformed })
2565
+ //// return transformed
2566
+ //// }
2567
+ // }))
2568
+ // this.expose_port = await portfinder.getPortPromise({ port: this.port })
2569
+ // console.log("EXPOSE_PORT", this.expose_port)
2570
+ // await new Promise((resolve, reject) => {
2571
+ // this.expose_server = this.expose_app.listen(this.expose_port, () => {
2572
+ // console.log(`Server listening on port ${this.expose_port}`)
2573
+ // resolve()
2574
+ // });
2575
+ // this.exposeTerminator = createHttpTerminator({
2576
+ // server: this.expose_server
2577
+ // });
2578
+ // })
2564
2579
  }
2565
2580
  }
2566
2581
  module.exports = Server
@@ -1073,6 +1073,8 @@ body.dark .line.align-top h3 .col .btn.label {
1073
1073
  .line.align-top h3 .col {
1074
1074
  padding-left: 10px;
1075
1075
  flex-grow: 1;
1076
+ min-width: 0;
1077
+ word-wrap: break-word;
1076
1078
  }
1077
1079
  .line.align-top h3 {
1078
1080
  display: flex;
@@ -1465,6 +1467,9 @@ body.dark .btn2 {
1465
1467
  body.dark .btn2:hover {
1466
1468
  background: rgba(255,255,255,0.06);
1467
1469
  }
1470
+ .browser-options {
1471
+ padding: 10px;
1472
+ }
1468
1473
  .btn2 {
1469
1474
  background: none;
1470
1475
  font-weight: normal;
@@ -561,10 +561,10 @@ body.dark .loader-container {
561
561
  </div>
562
562
  -->
563
563
  <div class='grid-btns'>
564
- <a class='btn2' href="/?mode=help"><div><i class="fa-regular fa-face-smile"></i></div><div>help</div></a>
565
- <a class='btn2' href="/?mode=settings"><div><i class="fa-solid fa-gear"></i></div><div>config</div></a>
566
- <a class='btn2' href="/"><div><i class="fa-solid fa-house"></i></div><div>home</div></a>
567
- <button class='btn2' id='new-window' title='open a new window'><div><i class="fa-solid fa-plus"></i></div><div> window</div></button>
564
+ <a class='btn2' href="/?mode=help"><div><i class="fa-regular fa-face-smile"></i></div><div>Community</div></a>
565
+ <a class='btn2' href="/?mode=settings"><div><i class="fa-solid fa-gear"></i></div><div>Settings</div></a>
566
+ <a class='btn2' href="/"><div><i class="fa-solid fa-house"></i></div><div>Home</div></a>
567
+ <button class='btn2' id='new-window' title='open a new window'><div><i class="fa-solid fa-plus"></i></div><div>Window</div></button>
568
568
  </div>
569
569
  <!--
570
570
  <div class='grid-btns'>
@@ -66,9 +66,10 @@
66
66
  padding: 20px 0;
67
67
  }
68
68
  .titleview h1 {
69
+ font-style: italic;
69
70
  word-break: break-word;
70
- font-size: 40px;
71
- text-transform: uppercase;
71
+ font-size: 50px;
72
+ font-family: Georgia;
72
73
  letter-spacing: -1px;
73
74
  }
74
75
  .item > .d {
@@ -261,7 +262,7 @@ body.dark .item .tile .badge {
261
262
  <div class='item'>
262
263
  <label><i class="fa-brands fa-discord"></i> Discord</label>
263
264
  <div>
264
- Having issues? Generate a logs.zip file, and share it in <a class='link' href="https://discord.gg/TQdNwadtE4" target="_blank">Pinokio Discord</a>
265
+ Have questions? Something not working? Generate a logs.zip file, and share it in <a class='link' href="https://discord.gg/TQdNwadtE4" target="_blank">Pinokio Discord</a>
265
266
  <div class='footer'>
266
267
  <div id='genlog' class='btn'>Generate logs.zip</div>
267
268
  <a id='downloadlogs' download class='hidden btn' href="/pinokio/logs.zip"><i class="fa-solid fa-download"></i> Download logs.zip</a>
@@ -123,10 +123,12 @@ header .runner {
123
123
  <% if (ishome) { %>
124
124
  <div class='nav-btns'>
125
125
  <a class='btn2' id='explore'><div><i class="fa-solid fa-globe"></i></div><div>Discover</div></a>
126
+ <a class='btn2' href="/?mode=help"><div><i class="fa-regular fa-face-smile"></i></div><div>Community</div></a>
126
127
  <% if (agent === "electron") { %>
127
128
  <a class='btn2' data-filepath="<%=filepath%>"><div><i class="fa-regular fa-folder-open"></i></div><div>Files</div></a>
128
129
  <% } %>
129
- <a id='wifi' data-proxy="<%=proxy.proxy%>" class='btn2'><div><i class="fa-solid fa-wifi"></i></div><div>WiFi</div></a>
130
+ <a id='wifi' data-proxy="<%=proxy.proxy%>" class='btn2'><div><i class="fa-solid fa-wifi"></i></div><div>WiFi Share</div></a>
131
+ <a href="/" target="_blank" class='btn2'><div><i class="fa-solid fa-arrow-up-right-from-square"></i></div><div>Popout</div></a>
130
132
  <!--
131
133
  <a class='btn2' id='report'><div><i class="fa-solid fa-bug"></i></div><div>Report Bug</div></a>
132
134
  <a class='btn2' href='https://discord.gg/TQdNwadtE4' target="_blank"><div><i class="fa-brands fa-discord"></i></div><div>Discord</div></a>
@@ -137,7 +139,6 @@ header .runner {
137
139
  <!--
138
140
  <a class='btn2' id='report'><div><i class="fa-solid fa-question"></i></div><div>Help</div></a>
139
141
  -->
140
- <a class='btn2' href="/?mode=help"><div><i class="fa-regular fa-face-smile"></i></div><div>Help</div></a>
141
142
  </div>
142
143
  <button id='new-window' title='open a new window' class='btn2'><i class="fa-solid fa-plus"></i></button>
143
144
  <% } %>
@@ -172,6 +173,12 @@ header .runner {
172
173
  <div id='terminal' class='hidden'></div>
173
174
  <div class='container'>
174
175
  <% if (ishome) { %>
176
+ <!--
177
+ <div class='browser-options'>
178
+ <a href="/" target="_blank" class='btn'><div><i class="fa-solid fa-arrow-up-right-from-square"></i> Open in Browser</div></a>
179
+ <a id='wifi' data-proxy="<%=proxy.proxy%>" class='btn'><div><i class="fa-solid fa-wifi"></i> WiFi Sharing</div></a>
180
+ </div>
181
+ -->
175
182
  <% if (running.length > 0) { %>
176
183
  <div class='running-apps'>
177
184
  <div class='header-label'>Running</div>
@@ -641,6 +648,8 @@ document.addEventListener("click", (e) => {
641
648
  console.log("packet", packet)
642
649
  if (packet.type === "result") {
643
650
  socket.close()
651
+ target.querySelector("i.fa-stop").className = "fa-solid fa-check"
652
+ target.querySelector("i.fa-spin").classList.add("hidden")
644
653
  n.Noty({
645
654
  text: `stopped ${src}`,
646
655
  silent: true
@@ -721,6 +730,8 @@ document.addEventListener("click", (e) => {
721
730
  },
722
731
  showConfirmButton: false,
723
732
  html: `<div class='min-modal'>
733
+ <div>Access Pinokio from</div>
734
+ <div>any local network device</div>
724
735
  <div><img src="<%=qr%>"></div>
725
736
  <a href="<%=proxy.proxy%>" target="_blank"><%=proxy.proxy%></a>
726
737
  </div>`
@@ -66,9 +66,10 @@
66
66
  padding: 20px 0;
67
67
  }
68
68
  .titleview h1 {
69
+ font-style: italic;
69
70
  word-break: break-word;
70
- font-size: 40px;
71
- text-transform: uppercase;
71
+ font-size: 50px;
72
+ font-family: Georgia;
72
73
  letter-spacing: -1px;
73
74
  }
74
75
  .item > .d {
@@ -424,53 +425,68 @@ document.addEventListener("DOMContentLoaded", async () => {
424
425
  })
425
426
  }
426
427
  <% } %>
428
+ // document.querySelector("[name=home]").addEventListener("input", (e) => {
429
+ // let sep = "<%=platform === 'win32' ? '\\' : '/'%>"
430
+ // document.querySelector("[name=drive]").value = e.target.value + sep + "drive"
431
+ // })
427
432
  document.querySelector("form").addEventListener("submit", async (e) => {
428
433
  e.preventDefault()
429
434
  e.stopPropagation()
430
435
  let val = document.querySelector(`[name=home]`).value
431
436
  if (/.*\s+.*/.test(val)) {
432
437
  alert("Please use a home path that does NOT include a space")
433
- document.querySelector(".homepath").focus()
434
- } else {
435
- document.querySelector(".loading").classList.remove("hidden")
436
- document.querySelector("#save").classList.add("hidden")
437
- document.querySelector(".homepath").setAttribute("disabled", "disabled")
438
- let theme = document.querySelector(`[name=theme]`).value
439
- let r = await fetch("/config", {
440
- method: "post",
441
- headers: { "Content-Type": "application/json" },
442
- body: JSON.stringify({
443
- home: (val && val.length > 0 ? val : null),
444
- theme
445
- })
446
- }).then((res) => {
447
- return res.json()
438
+ document.querySelector("[name=home]").focus()
439
+ return
440
+ }
441
+
442
+ // let drive = document.querySelector(`[name=drive]`).value
443
+ // if (/.*\s+.*/.test(drive)) {
444
+ // alert("Please use a drive path that does NOT include a space")
445
+ // document.querySelector("[name=drive]").focus()
446
+ // return
447
+ // }
448
+
449
+
450
+ document.querySelector(".loading").classList.remove("hidden")
451
+ document.querySelector("#save").classList.add("hidden")
452
+ document.querySelector("[name=home]").setAttribute("disabled", "disabled")
453
+ // document.querySelector("[name=drive]").setAttribute("disabled", "disabled")
454
+ let theme = document.querySelector(`[name=theme]`).value
455
+ let r = await fetch("/config", {
456
+ method: "post",
457
+ headers: { "Content-Type": "application/json" },
458
+ body: JSON.stringify({
459
+ home: (val && val.length > 0 ? val : null),
460
+ // drive: (drive && drive.length > 0 ? drive : null),
461
+ theme
448
462
  })
449
- if (r.success) {
450
- //alert("Successfully updated the pinokio home to " + val)
451
- fetch("/restart", {
452
- method: "post"
453
- }, () => {
454
- })
455
- setInterval(async () => {
456
- try {
457
- let res = await fetch("/check").then((res) => {
458
- return res.json()
459
- })
460
- if (res.success) {
461
- document.querySelector(".loading").classList.add("hidden")
462
- setTimeout(() => {
463
- location.href = "/"
464
- }, 1000)
465
- }
466
- } catch (e) {
467
- console.log(e)
463
+ }).then((res) => {
464
+ return res.json()
465
+ })
466
+ if (r.success) {
467
+ //alert("Successfully updated the pinokio home to " + val)
468
+ fetch("/restart", {
469
+ method: "post"
470
+ }, () => {
471
+ })
472
+ setInterval(async () => {
473
+ try {
474
+ let res = await fetch("/check").then((res) => {
475
+ return res.json()
476
+ })
477
+ if (res.success) {
478
+ document.querySelector(".loading").classList.add("hidden")
479
+ setTimeout(() => {
480
+ location.href = "/"
481
+ }, 1000)
468
482
  }
469
- }, 1000)
470
- } else if (r.error) {
471
- alert(r.error)
472
- location.href = location.href
473
- }
483
+ } catch (e) {
484
+ console.log(e)
485
+ }
486
+ }, 1000)
487
+ } else if (r.error) {
488
+ alert(r.error)
489
+ location.href = location.href
474
490
  }
475
491
  })
476
492
  })