diff --git a/json/config/favorites.json b/json/config/favorites.json
new file mode 100644
index 0000000..c2e739b
--- /dev/null
+++ b/json/config/favorites.json
@@ -0,0 +1 @@
+{"C:/Users/clarkjr1836/Desktop/yb":"yb","C:/Users/clarkjr1836/Desktop/bot":"bot"}
\ No newline at end of file
diff --git a/scripts/contextmenu/createcontext.js b/scripts/contextmenu/createcontext.js
index bcf2cfb..9b8d809 100755
--- a/scripts/contextmenu/createcontext.js
+++ b/scripts/contextmenu/createcontext.js
@@ -7,8 +7,8 @@ module.exports = (e, target, window) => {
if (target.classList.contains('file') || (target.parentElement && target.parentElement.classList.contains('file'))) {
ctxf.style.display = 'block';
ctxf.previousElementSibling.style.display = 'block';
- if (target.classList.contains('file')) {window.kade.currentFolder = target.children[1].innerHTML;}
- else {window.kade.currentFolder = target.parentElement.children[1].innerHTML;}
+ if (target.classList.contains('file')) {window.kade.currentFolder = target.children[1].innerHTML.trim();}
+ else {window.kade.currentFolder = target.parentElement.children[1].innerHTML.trim();}
} else {
ctxf.style.display = 'none';
ctxf.previousElementSibling.style.display = 'none';
diff --git a/scripts/contextmenu/pin.js b/scripts/contextmenu/pin.js
new file mode 100644
index 0000000..5d6191f
--- /dev/null
+++ b/scripts/contextmenu/pin.js
@@ -0,0 +1,36 @@
+const fs = require('fs');
+const path = require('path');
+
+const createToast = require('../toast/createtoast');
+const refresh = require('../fileview/refresh');
+const newToast = require("../toast/createtoast");
+
+module.exports = () => {
+ let pins;
+ if (fs.existsSync(path.join(__dirname, '../../', '/json/config/favorites.json'))) {
+ pins = require('../../json/config/favorites.json');
+ } else {pins = {};}
+ let fta = window.kade.currentFolder.trim();
+ if (Object.keys(pins).includes(`${window.kade.cpath.replace(/\\+/gm, '/')}/${fta}`)) {
+ return createToast("Already pinned", "That folder is already pinned!");
+ }
+ let tr = `${window.kade.cpath.replace(/\\+/gm, '/')}/${fta}`;
+ pins[tr] = fta;
+ let cfc = document.getElementById('custom-favorites-container');
+ let fav = document.createElement('div');
+ ['favorites-button', 'folder-pin', 'nosel'].forEach(x => fav.classList.add(x));
+ fav.innerHTML = fta;
+ fav.onclick = () => {refresh(tr);};
+ console.log(fta, window.kade.cpath.replace(/\\+/gm, '/'));
+ cfc.appendChild(fav);
+ createToast(
+ "Folder Pinned", [`Folder "${fta}" was successfully pinned! You can now access it permanently in your sidebar!"`, `${window.kade.cpath.replace(/\\+/gm, '/')}/${fta}`], undefined, false, 5,
+ () => {
+ refresh(tr);
+ require('electron').clipboard.writeText(`${window.kade.cpath.replace(/\\+/gm, '/')}`);
+ newToast("Copied!", "The folder's path has been copied to your clipboard.", "#19df46");
+ }
+ );
+ try {fs.writeFileSync(path.join(__dirname, '../../', '/json/config/favorites.json'), JSON.stringify(pins));}
+ catch {createToast("Error", "Your pin was not saved for some reason. Please restart or reload (ctrl+shift+r) the app and try again.", "#ff557a");}
+};
\ No newline at end of file
diff --git a/scripts/contextmenu/rename-folder.js b/scripts/contextmenu/rename-folder.js
index 310ae45..df9185a 100644
--- a/scripts/contextmenu/rename-folder.js
+++ b/scripts/contextmenu/rename-folder.js
@@ -43,7 +43,7 @@ module.exports = () => {
conf.innerHTML = 'Rename';
conf.onclick = () => {
try {
- input.value.trim();
+ input.value = input.value.trim();
if (!input.value.length) {return;}
if (fs.existsSync(path.join(window.kade.cpath, input.value))) {
if (!input.value.match(/^.+\(\d\)$/gm)) {input.value += ' (1)';}
diff --git a/scripts/startup/changelog.js b/scripts/startup/changelog.js
index 4c33789..1a46812 100755
--- a/scripts/startup/changelog.js
+++ b/scripts/startup/changelog.js
@@ -59,7 +59,7 @@ module.exports = () => {
});
});
- clww.style = `height: ${modalOut.clientHeight - 6};`; // TODO cry enough tears that they magically make this line work
+ clww.style = `height: ${modalOut.clientHeight - 6};`;
let msm = new Mousetrap(modal);
msm.bind('esc', () => {