From 17bfc3b1d0ad126f9c33deb02a4da20d978b267c Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Wed, 20 Apr 2022 02:13:00 -0600 Subject: [PATCH] 1.7.0 -> File opening! --- json/changelogs/1.7.0.json | 1 + package-lock.json | 4 ++-- package.json | 2 +- scripts/fileview/load/load.js | 1 + scripts/fileview/load/render.js | 13 ++++++++++++- 5 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 json/changelogs/1.7.0.json diff --git a/json/changelogs/1.7.0.json b/json/changelogs/1.7.0.json new file mode 100644 index 0000000..7a2b76e --- /dev/null +++ b/json/changelogs/1.7.0.json @@ -0,0 +1 @@ +{"log":{"File opening":["Files now open!!","I know right, a file explorer that opens files. Revolutionary.","This feature is dependent on you being on a version of Windows where PowerShell exists. Whether or not it works every single time is a bit untested, so it could cause some twitchy stuff to happen. This has not been written for Linux or Mac yet."]},"version":{"name":"Alpha","semver":"1.7.0"}} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 7bc5984..0b67d86 100755 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "filekade", - "version": "1.6.4", + "version": "1.7.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "filekade", - "version": "1.6.4", + "version": "1.7.0", "license": "ISC", "dependencies": { "chalk": "^4.1.2", diff --git a/package.json b/package.json index ce35ebd..c297ada 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "filekade", - "version": "1.6.4", + "version": "1.7.0", "description": "A file explorer (primarily a learning experience for me)", "main": "main.js", "scripts": { diff --git a/scripts/fileview/load/load.js b/scripts/fileview/load/load.js index 944f913..306bbe7 100755 --- a/scripts/fileview/load/load.js +++ b/scripts/fileview/load/load.js @@ -16,6 +16,7 @@ module.exports = (check=false) => { for (const file of ldir) { let ofile = {}; ofile.icon = fileIcon(`${dir}/${file}`, file); + ofile.trueName = file; ofile.name = trimext.includes(path.extname(file)) ? file.slice(0, file.length - path.extname(file).length) : file; try {ofile.type = fs.lstatSync(`${dir}/${file}`).isDirectory() ? "File Folder" : (extensions[(file.startsWith('.') ? file : path.extname(file)).slice(1)] || "File");} catch {ofile.type = `${path.extname(file)} File`.trim();} diff --git a/scripts/fileview/load/render.js b/scripts/fileview/load/render.js index d15d11f..5963cbe 100755 --- a/scripts/fileview/load/render.js +++ b/scripts/fileview/load/render.js @@ -1,4 +1,7 @@ +const cp = require('child_process'); + const loadHierarchy = require("../hierarchy"); +const newToast = require('../../toast/createtoast'); const isOverflowing = require('../../dep/overflowing'); @@ -16,7 +19,15 @@ module.exports = (dir, options) => { if (file.type.toLowerCase().includes('folder')) {cfc.classList.add('folder');} cfc.onclick = function () { window.kade.elc = true; - if (cfc.classList.contains('file-active')) {if (file.dir) {refresh(`${window.kade.cpath}/${file.name}`);}} + if (cfc.classList.contains('file-active')) { + if (file.dir) {refresh(`${window.kade.cpath}/${file.name}`);} + else { + try {cp.exec(`${window.kade.cpath}/${file.trueName}`, {shell: 'powershell.exe'}, (error) => { + if (error) {newToast("Error", "Unable to open file.", "#a4052b");} + });} + catch {newToast("Error", "Unable to open file.", "#a4052b");} + } + } cfc.classList.add('file-active'); if (window.kade.cl && !cfc.isSameNode(window.kade.cl)) {window.kade.cl.classList.remove('file-active');} window.kade.cl = cfc;