pin folder to sidebar

sidebar
Kit Kasune 3 years ago
parent ceb5dc1925
commit 0876d9fb4b
  1. 1
      json/config/favorites.json
  2. 4
      scripts/contextmenu/createcontext.js
  3. 36
      scripts/contextmenu/pin.js
  4. 2
      scripts/contextmenu/rename-folder.js
  5. 2
      scripts/startup/changelog.js

@ -0,0 +1 @@
{"C:/Users/clarkjr1836/Desktop/yb":"yb","C:/Users/clarkjr1836/Desktop/bot":"bot"}

@ -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';

@ -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!"`, `<em>${window.kade.cpath.replace(/\\+/gm, '/')}/${fta}</em>`], undefined, false, 5,
() => {
refresh(tr);
require('electron').clipboard.writeText(`${window.kade.cpath.replace(/\\+/gm, '/')}`);
newToast("Copied!", "<em>The folder's path has been copied to your clipboard.</em>", "#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");}
};

@ -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)';}

@ -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', () => {

Loading…
Cancel
Save