mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
chore(cloudcmd) putout: apply-destructuring
This commit is contained in:
parent
ba5fee3f94
commit
b62984d540
35 changed files with 338 additions and 161 deletions
|
|
@ -305,7 +305,9 @@ function checkUpdate() {
|
|||
}
|
||||
|
||||
function showUpdateInfo(data) {
|
||||
const version = data.version;
|
||||
const {
|
||||
version
|
||||
} = data;
|
||||
|
||||
if (version === Info.version)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,9 @@ function main(callback) {
|
|||
'**[v{{ version }}]' +
|
||||
'(' + link + 'v{{ version }})**\n';
|
||||
|
||||
const version = Info.version;
|
||||
const {
|
||||
version
|
||||
} = Info;
|
||||
|
||||
cl((error, versionNew) => {
|
||||
if (error)
|
||||
|
|
@ -52,7 +54,9 @@ function replaceVersion(name, version, versionNew, callback) {
|
|||
}
|
||||
|
||||
function cl(callback) {
|
||||
const argv = process.argv;
|
||||
const {
|
||||
argv
|
||||
} = process;
|
||||
const length = argv.length - 1;
|
||||
const last = process.argv[length];
|
||||
const regExp = /^--(major|minor|patch)$/;
|
||||
|
|
|
|||
|
|
@ -55,8 +55,11 @@ function CloudCmdProto(DOM) {
|
|||
|
||||
const CloudCmd = this;
|
||||
const Info = DOM.CurrentInfo;
|
||||
const Storage = DOM.Storage;
|
||||
const Files = DOM.Files;
|
||||
|
||||
const {
|
||||
Storage,
|
||||
Files
|
||||
} = DOM;
|
||||
|
||||
this.log = log;
|
||||
this.prefix = '';
|
||||
|
|
@ -97,10 +100,13 @@ function CloudCmdProto(DOM) {
|
|||
const p = params;
|
||||
|
||||
const refresh = p.isRefresh;
|
||||
const panel = p.panel;
|
||||
const history = p.history;
|
||||
const noCurrent = p.noCurrent;
|
||||
const currentName = p.currentName;
|
||||
|
||||
const {
|
||||
panel,
|
||||
history,
|
||||
noCurrent,
|
||||
currentName
|
||||
} = p;
|
||||
|
||||
let panelChanged;
|
||||
if (!noCurrent)
|
||||
|
|
@ -154,7 +160,7 @@ function CloudCmdProto(DOM) {
|
|||
* should be called from config.js only
|
||||
* after successful update on server
|
||||
*/
|
||||
|
||||
|
||||
if (key === 'password')
|
||||
return;
|
||||
|
||||
|
|
@ -317,14 +323,16 @@ function CloudCmdProto(DOM) {
|
|||
callback = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
|
||||
const panel = options.panel || Info.panel;
|
||||
const path = DOM.getCurrentDirPath(panel);
|
||||
|
||||
const isRefresh = true;
|
||||
const history = false;
|
||||
const noCurrent = options ? options.noCurrent : false;
|
||||
const currentName = options.currentName;
|
||||
const {
|
||||
currentName
|
||||
} = options;
|
||||
|
||||
CloudCmd.loadDir({
|
||||
path,
|
||||
|
|
@ -348,11 +356,15 @@ function CloudCmdProto(DOM) {
|
|||
*/
|
||||
function ajaxLoad(path, options, panel, callback) {
|
||||
const create = (error, json) => {
|
||||
const RESTful = DOM.RESTful;
|
||||
const {
|
||||
RESTful
|
||||
} = DOM;
|
||||
const name = options.currentName || Info.name;
|
||||
const obj = jonny.parse(json);
|
||||
const isRefresh = options.refresh;
|
||||
const noCurrent = options.noCurrent;
|
||||
const {
|
||||
noCurrent
|
||||
} = options;
|
||||
|
||||
if (!isRefresh && json)
|
||||
return createFileTable(obj, panel, options, callback);
|
||||
|
|
@ -414,7 +426,9 @@ function CloudCmdProto(DOM) {
|
|||
const names = ['file', 'path', 'link', 'pathLink'];
|
||||
|
||||
Files.get(names, (error, templFile, templPath, templLink, templPathLink) => {
|
||||
const Dialog = DOM.Dialog;
|
||||
const {
|
||||
Dialog
|
||||
} = DOM;
|
||||
const panel = panelParam || DOM.getPanel();
|
||||
const {prefix} = CloudCmd;
|
||||
|
||||
|
|
@ -426,7 +440,9 @@ function CloudCmdProto(DOM) {
|
|||
if (error)
|
||||
return Dialog.alert(TITLE, error.responseText);
|
||||
|
||||
const childNodes = panel.childNodes;
|
||||
const {
|
||||
childNodes
|
||||
} = panel;
|
||||
let i = childNodes.length;
|
||||
|
||||
while (i--)
|
||||
|
|
@ -510,10 +526,10 @@ function CloudCmdProto(DOM) {
|
|||
}
|
||||
|
||||
this.goToParentDir = () => {
|
||||
const dir = Info.dir;
|
||||
const {
|
||||
dir,
|
||||
dirPath,
|
||||
parentDirPath,
|
||||
parentDirPath
|
||||
} = Info;
|
||||
|
||||
if (dirPath === parentDirPath)
|
||||
|
|
|
|||
|
|
@ -108,16 +108,18 @@ function BufferProto() {
|
|||
exec.parallel([copy, cut], (error, cp, ct) => {
|
||||
const opStr = cp ? 'copy' : 'move';
|
||||
const opData = cp || ct;
|
||||
const Operation = CloudCmd.Operation;
|
||||
const {
|
||||
Operation
|
||||
} = CloudCmd;
|
||||
const msg = 'Path is same!';
|
||||
const path = Info.dirPath;
|
||||
|
||||
if (!error && !cp && !ct)
|
||||
error = 'Buffer is empty!';
|
||||
|
||||
|
||||
if (error)
|
||||
return showMessage(error);
|
||||
|
||||
|
||||
const data = jonny.parse(opData);
|
||||
data.to = path;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@ const {
|
|||
} = DOM;
|
||||
|
||||
module.exports = (items) => {
|
||||
const Dialog = DOM.Dialog;
|
||||
const {
|
||||
Dialog
|
||||
} = DOM;
|
||||
|
||||
if (items.length)
|
||||
Images.show('top');
|
||||
|
|
|
|||
|
|
@ -20,7 +20,9 @@ const isContainClass = (element, className) => {
|
|||
if (Array.isArray(className))
|
||||
return className.some(currify(isContainClass, element));
|
||||
|
||||
const classList = element.classList;
|
||||
const {
|
||||
classList
|
||||
} = element;
|
||||
|
||||
return classList.contains(className);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -47,7 +47,9 @@ function getElement() {
|
|||
/* Функция создаёт картинку загрузки */
|
||||
module.exports.loading = () => {
|
||||
const element = getElement();
|
||||
const classList = element.classList;
|
||||
const {
|
||||
classList
|
||||
} = element;
|
||||
|
||||
classList.add(LOADING, LoadingImage);
|
||||
classList.remove(ERROR, HIDDEN);
|
||||
|
|
@ -58,7 +60,9 @@ module.exports.loading = () => {
|
|||
/* Функция создаёт картинку ошибки загрузки */
|
||||
module.exports.error = () => {
|
||||
const element = getElement();
|
||||
const classList = element.classList;
|
||||
const {
|
||||
classList
|
||||
} = element;
|
||||
|
||||
classList.add(ERROR);
|
||||
classList.remove(HIDDEN, LOADING, LoadingImage);
|
||||
|
|
@ -80,7 +84,7 @@ function show(position, panel) {
|
|||
const refreshButton = DOM.getRefreshButton(panel);
|
||||
|
||||
let current;
|
||||
|
||||
|
||||
if (position === 'top') {
|
||||
current = refreshButton.parentElement;
|
||||
} else {
|
||||
|
|
@ -123,7 +127,7 @@ module.exports.hide = () => {
|
|||
module.exports.setProgress = (value, title) => {
|
||||
const DATA = 'data-progress';
|
||||
const element = Images.get();
|
||||
|
||||
|
||||
if (!element)
|
||||
return Images;
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ function CmdProto() {
|
|||
|
||||
if (name === '..')
|
||||
return '';
|
||||
|
||||
|
||||
return name;
|
||||
};
|
||||
|
||||
|
|
@ -247,7 +247,7 @@ function CmdProto() {
|
|||
RESTful.read(link + query, (error, size) => {
|
||||
if (error)
|
||||
return;
|
||||
|
||||
|
||||
DOM.setCurrentSize(size, current);
|
||||
exec(callback, current);
|
||||
Images.hide();
|
||||
|
|
@ -319,7 +319,9 @@ function CmdProto() {
|
|||
*/
|
||||
this.getCurrentData = (callback, currentFile) => {
|
||||
let hash;
|
||||
const Dialog = DOM.Dialog;
|
||||
const {
|
||||
Dialog
|
||||
} = DOM;
|
||||
const Info = DOM.CurrentInfo;
|
||||
const current = currentFile || DOM.getCurrentFile();
|
||||
const path = DOM.getCurrentPath(current);
|
||||
|
|
@ -332,7 +334,9 @@ function CmdProto() {
|
|||
if (itype.object(data))
|
||||
data = jonny.stringify(data);
|
||||
|
||||
const length = data.length;
|
||||
const {
|
||||
length
|
||||
} = data;
|
||||
|
||||
if (hash && length < ONE_MEGABYTE)
|
||||
DOM.saveDataToStorage(path, data, hash);
|
||||
|
|
@ -448,7 +452,9 @@ function CmdProto() {
|
|||
*/
|
||||
this.expandSelection = () => {
|
||||
const msg = 'expand';
|
||||
const files = CurrentInfo.files;
|
||||
const {
|
||||
files
|
||||
} = CurrentInfo;
|
||||
|
||||
selectByPattern(msg, files);
|
||||
};
|
||||
|
|
@ -458,8 +464,10 @@ function CmdProto() {
|
|||
*/
|
||||
this.shrinkSelection = () => {
|
||||
const msg = 'shrink';
|
||||
const files = CurrentInfo.files;
|
||||
|
||||
const {
|
||||
files
|
||||
} = CurrentInfo;
|
||||
|
||||
selectByPattern(msg, files);
|
||||
};
|
||||
|
||||
|
|
@ -540,7 +548,9 @@ function CmdProto() {
|
|||
* check storage hash
|
||||
*/
|
||||
this.checkStorageHash = (name, callback) => {
|
||||
const parallel = exec.parallel;
|
||||
const {
|
||||
parallel
|
||||
} = exec;
|
||||
const loadHash = DOM.loadCurrentHash;
|
||||
const nameHash = name + '-hash';
|
||||
const getStoreHash = exec.with(Storage.get, nameHash);
|
||||
|
|
@ -694,7 +704,7 @@ function CmdProto() {
|
|||
|
||||
return DOM.hide(panel);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* remove child of element
|
||||
* @param pChild
|
||||
|
|
@ -748,7 +758,9 @@ function CmdProto() {
|
|||
* @currentFile
|
||||
*/
|
||||
this.renameCurrent = (current) => {
|
||||
const Dialog = DOM.Dialog;
|
||||
const {
|
||||
Dialog
|
||||
} = DOM;
|
||||
|
||||
if (!DOM.isCurrentFile(current))
|
||||
current = DOM.getCurrentFile();
|
||||
|
|
@ -824,7 +836,7 @@ function CmdProto() {
|
|||
let dataName = panel.getAttribute('data-name');
|
||||
|
||||
TabPanel[dataName] = name;
|
||||
|
||||
|
||||
panel = panelPassive;
|
||||
dataName = panel.getAttribute('data-name');
|
||||
|
||||
|
|
@ -866,7 +878,9 @@ function CmdProto() {
|
|||
this.goToDirectory = () => {
|
||||
const msg = 'Go to directory:';
|
||||
const path = CurrentInfo.dirPath;
|
||||
const Dialog = DOM.Dialog;
|
||||
const {
|
||||
Dialog
|
||||
} = DOM;
|
||||
const cancel = false;
|
||||
const setPath = (path) => ({
|
||||
path
|
||||
|
|
@ -879,7 +893,9 @@ function CmdProto() {
|
|||
|
||||
this.duplicatePanel = () => {
|
||||
const Info = CurrentInfo;
|
||||
const isDir = Info.isDir;
|
||||
const {
|
||||
isDir
|
||||
} = Info;
|
||||
const panel = Info.panelPassive;
|
||||
const noCurrent = !Info.isOnePanel;
|
||||
|
||||
|
|
@ -901,11 +917,12 @@ function CmdProto() {
|
|||
|
||||
this.swapPanels = () => {
|
||||
const Info = CurrentInfo;
|
||||
const {panel} = Info;
|
||||
const {files} = Info;
|
||||
const {element} = Info;
|
||||
|
||||
const panelPassive = Info.panelPassive;
|
||||
const {
|
||||
panel,
|
||||
files,
|
||||
element,
|
||||
panelPassive
|
||||
} = Info;
|
||||
|
||||
const dirPath = DOM.getCurrentDirPath();
|
||||
const dirPathPassive = DOM.getNotCurrentDirPath();
|
||||
|
|
@ -922,7 +939,9 @@ function CmdProto() {
|
|||
path: dirPathPassive,
|
||||
panel
|
||||
}, () => {
|
||||
const files = Info.files;
|
||||
const {
|
||||
files
|
||||
} = Info;
|
||||
const length = files.length - 1;
|
||||
|
||||
if (currentIndex > length)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,9 @@ module.exports = (name, options, callback = options) => {
|
|||
const module = findObjByNameInArr(modules.remote, name);
|
||||
|
||||
const isArray = itype.array(module.local);
|
||||
const version = module.version;
|
||||
const {
|
||||
version
|
||||
} = module;
|
||||
|
||||
let remoteTmpls;
|
||||
let local;
|
||||
|
|
|
|||
|
|
@ -194,8 +194,12 @@ function RESTful() {
|
|||
dataType : p.dataType,
|
||||
error : (jqXHR) => {
|
||||
const response = jqXHR.responseText;
|
||||
const statusText = jqXHR.statusText;
|
||||
const status = jqXHR.status;
|
||||
|
||||
const {
|
||||
statusText,
|
||||
status
|
||||
} = jqXHR;
|
||||
|
||||
const text = status === 404 ? response : statusText;
|
||||
const encoded = encode(text);
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,9 @@ function _onEnd(currentName) {
|
|||
function _loadFile(dir, n, file, callback) {
|
||||
let i = 0;
|
||||
|
||||
const name = file.name;
|
||||
const {
|
||||
name
|
||||
} = file;
|
||||
const path = dir + name;
|
||||
const {prefixURL} = CloudCmd;
|
||||
const api = prefixURL + FS;
|
||||
|
|
|
|||
|
|
@ -52,7 +52,9 @@ function setState(state) {
|
|||
|
||||
module.exports.getValue = (name, element) => {
|
||||
const el = getElementByName(name, element);
|
||||
const type = el.type;
|
||||
const {
|
||||
type
|
||||
} = el;
|
||||
|
||||
switch(type) {
|
||||
case 'checkbox':
|
||||
|
|
@ -68,7 +70,9 @@ module.exports.getValue = (name, element) => {
|
|||
|
||||
module.exports.setValue = (name, value, element) => {
|
||||
const el = getElementByName(name, element);
|
||||
const type = el.type;
|
||||
const {
|
||||
type
|
||||
} = el;
|
||||
|
||||
switch(type) {
|
||||
case 'checkbox':
|
||||
|
|
|
|||
|
|
@ -56,7 +56,9 @@ function KeyProto() {
|
|||
}
|
||||
|
||||
function listener(event) {
|
||||
const keyCode = event.keyCode;
|
||||
const {
|
||||
keyCode
|
||||
} = event;
|
||||
const alt = event.altKey;
|
||||
const ctrl = event.ctrlKey;
|
||||
const shift = event.shiftKey;
|
||||
|
|
@ -121,14 +123,19 @@ function KeyProto() {
|
|||
let current = Info.element;
|
||||
let dataName;
|
||||
|
||||
const name = Info.name;
|
||||
const {
|
||||
name,
|
||||
panel,
|
||||
path,
|
||||
isDir
|
||||
} = Info;
|
||||
|
||||
const {Operation} = CloudCmd;
|
||||
const panel = Info.panel;
|
||||
const path = Info.path;
|
||||
const isDir = Info.isDir;
|
||||
|
||||
const keyCode = event.keyCode;
|
||||
const {
|
||||
keyCode
|
||||
} = event;
|
||||
|
||||
const alt = event.altKey;
|
||||
const shift = event.shiftKey;
|
||||
const ctrl = event.ctrlKey;
|
||||
|
|
@ -185,7 +192,7 @@ function KeyProto() {
|
|||
case Key.F2:
|
||||
DOM.renameCurrent(current);
|
||||
break;
|
||||
|
||||
|
||||
case Key.F3:
|
||||
if (shift)
|
||||
CloudCmd.Markdown.show(path);
|
||||
|
|
@ -326,7 +333,7 @@ function KeyProto() {
|
|||
case Key.RIGHT:
|
||||
if (!alt)
|
||||
return;
|
||||
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
dataName = Info.panel.getAttribute('data-name');
|
||||
|
|
@ -378,7 +385,7 @@ function KeyProto() {
|
|||
DOM.setCurrentFile(current);
|
||||
event.preventDefault();
|
||||
break;
|
||||
|
||||
|
||||
/* open directory */
|
||||
case Key.ENTER:
|
||||
if (Info.isDir)
|
||||
|
|
@ -386,7 +393,7 @@ function KeyProto() {
|
|||
path: path === '/' ? '/' : path + '/'
|
||||
});
|
||||
break;
|
||||
|
||||
|
||||
case Key.BACKSPACE:
|
||||
CloudCmd.goToParentDir();
|
||||
event.preventDefault();
|
||||
|
|
@ -461,7 +468,7 @@ function KeyProto() {
|
|||
if (ctrlMeta)
|
||||
Buffer.cut();
|
||||
break;
|
||||
|
||||
|
||||
case Key.V:
|
||||
if (ctrlMeta)
|
||||
Buffer.paste();
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@
|
|||
|
||||
const KEY = require('../key');
|
||||
const Info = DOM.CurrentInfo;
|
||||
const Dialog = DOM.Dialog;
|
||||
const {
|
||||
Dialog
|
||||
} = DOM;
|
||||
|
||||
const fullstore = require('fullstore/legacy');
|
||||
const store = fullstore('');
|
||||
|
|
@ -33,7 +35,9 @@ const rmFirst = (a) => {
|
|||
|
||||
module.exports = (key, event) => {
|
||||
const current = Info.element;
|
||||
const keyCode = event.keyCode;
|
||||
const {
|
||||
keyCode
|
||||
} = event;
|
||||
const prevStore = store();
|
||||
|
||||
const value = store(prevStore.concat(key));
|
||||
|
|
@ -118,7 +122,7 @@ module.exports = (key, event) => {
|
|||
|
||||
Dialog.prompt(TITLE, 'Find', '', {cancel: false})
|
||||
.then(find);
|
||||
|
||||
|
||||
return end();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,8 +21,12 @@ const {
|
|||
global.DOM = getDOM();
|
||||
global.CloudCmd = getCloudCmd();
|
||||
|
||||
const DOM = global.DOM;
|
||||
const Buffer = DOM.Buffer;
|
||||
const {
|
||||
DOM
|
||||
} = global;
|
||||
const {
|
||||
Buffer
|
||||
} = DOM;
|
||||
|
||||
const KEY = require(pathKey);
|
||||
const vim = require(pathVim);
|
||||
|
|
|
|||
|
|
@ -51,7 +51,9 @@ const execAll = currify((funcs, event) => {
|
|||
});
|
||||
|
||||
const Info = DOM.CurrentInfo;
|
||||
const Events = DOM.Events;
|
||||
const {
|
||||
Events
|
||||
} = DOM;
|
||||
const EventsFiles = {
|
||||
mousedown: exec.with(execIfNotUL, setCurrentFileByEvent),
|
||||
click: execAll([
|
||||
|
|
@ -115,9 +117,13 @@ module.exports.initKeysPanel = () => {
|
|||
return;
|
||||
|
||||
Events.addClick(keysElement, ({target}) => {
|
||||
const id = target.id;
|
||||
const {
|
||||
id
|
||||
} = target;
|
||||
const operation = (name) => {
|
||||
const Operation = CloudCmd.Operation;
|
||||
const {
|
||||
Operation
|
||||
} = CloudCmd;
|
||||
const fn = Operation.show.bind(null, name);
|
||||
|
||||
return fn;
|
||||
|
|
@ -138,7 +144,7 @@ module.exports.initKeysPanel = () => {
|
|||
'shift~' : CloudCmd.Terminal.show,
|
||||
'contact' : CloudCmd.Contact.show,
|
||||
};
|
||||
|
||||
|
||||
exec(clickFuncs[id]);
|
||||
});
|
||||
};
|
||||
|
|
@ -304,7 +310,9 @@ function onTouch(event) {
|
|||
function onDragStart(event) {
|
||||
const {prefixURL} = CloudCmd;
|
||||
const element = getLIElement(event.target);
|
||||
const isDir = Info.isDir;
|
||||
const {
|
||||
isDir
|
||||
} = Info;
|
||||
let link = DOM.getCurrentLink(element);
|
||||
let name = DOM.getCurrentName(element);
|
||||
|
||||
|
|
@ -407,8 +415,11 @@ function dragndrop() {
|
|||
};
|
||||
|
||||
const onDrop = (event) => {
|
||||
const files = event.dataTransfer.files;
|
||||
const items = event.dataTransfer.items;
|
||||
const {
|
||||
files,
|
||||
items
|
||||
} = event.dataTransfer;
|
||||
|
||||
const {length: filesCount} = files;
|
||||
|
||||
event.preventDefault();
|
||||
|
|
@ -434,8 +445,12 @@ function dragndrop() {
|
|||
* to upload file from download bar
|
||||
*/
|
||||
const onDragOver = (event) => {
|
||||
const dataTransfer = event.dataTransfer;
|
||||
const effectAllowed = dataTransfer.effectAllowed;
|
||||
const {
|
||||
dataTransfer
|
||||
} = event;
|
||||
const {
|
||||
effectAllowed
|
||||
} = dataTransfer;
|
||||
|
||||
if (/move|linkMove/.test(effectAllowed))
|
||||
dataTransfer.dropEffect = 'move';
|
||||
|
|
@ -456,7 +471,9 @@ function dragndrop() {
|
|||
|
||||
function unload() {
|
||||
DOM.Events.add(['unload', 'beforeunload'], (event) => {
|
||||
const Key = CloudCmd.Key;
|
||||
const {
|
||||
Key
|
||||
} = CloudCmd;
|
||||
const isBind = Key && Key.isBind();
|
||||
|
||||
if (isBind)
|
||||
|
|
|
|||
|
|
@ -57,9 +57,10 @@ module.exports.init = async () => {
|
|||
Loading = false;
|
||||
};
|
||||
|
||||
const config = CloudCmd.config;
|
||||
|
||||
const {Key} = CloudCmd;
|
||||
const {
|
||||
config,
|
||||
Key
|
||||
} = CloudCmd;
|
||||
|
||||
let Element;
|
||||
let Template;
|
||||
|
|
|
|||
|
|
@ -8,8 +8,12 @@ CloudCmd.Contact = exports;
|
|||
const olark = require('@cloudcmd/olark');
|
||||
const Images = require('../dom/images');
|
||||
|
||||
const Events = DOM.Events;
|
||||
const Key = CloudCmd.Key;
|
||||
const {
|
||||
Events
|
||||
} = DOM;
|
||||
const {
|
||||
Key
|
||||
} = CloudCmd;
|
||||
|
||||
module.exports.show = show;
|
||||
module.exports.hide = hide;
|
||||
|
|
|
|||
|
|
@ -10,13 +10,19 @@ const exec = require('execon');
|
|||
const supermenu = require('supermenu');
|
||||
|
||||
const Info = DOM.CurrentInfo;
|
||||
const Dialog = DOM.Dialog;
|
||||
const config = CloudCmd.config;
|
||||
|
||||
const {
|
||||
Dialog,
|
||||
Images
|
||||
} = DOM;
|
||||
|
||||
const {
|
||||
config
|
||||
} = CloudCmd;
|
||||
|
||||
let Menu;
|
||||
|
||||
const TITLE = 'Edit';
|
||||
const Images = DOM.Images;
|
||||
|
||||
let MSG_CHANGED;
|
||||
const isLoading = fullstore();
|
||||
|
|
@ -68,7 +74,9 @@ module.exports.show = (options) => {
|
|||
.setOption('keyMap', 'default');
|
||||
|
||||
Info.getData((error, data) => {
|
||||
const path = Info.path;
|
||||
const {
|
||||
path
|
||||
} = Info;
|
||||
const name = getName();
|
||||
|
||||
if (error)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ const supermenu = require('supermenu');
|
|||
const reject = Promise.reject.bind(Promise);
|
||||
|
||||
const Info = DOM.CurrentInfo;
|
||||
const Dialog = DOM.Dialog;
|
||||
const {
|
||||
Dialog
|
||||
} = DOM;
|
||||
|
||||
const TITLE = 'Edit Names';
|
||||
const alert = currify(Dialog.alert, TITLE);
|
||||
|
|
@ -56,7 +58,7 @@ module.exports.show = (options) => {
|
|||
.disableKey();
|
||||
|
||||
CloudCmd.Edit.show(config);
|
||||
|
||||
|
||||
return CloudCmd.Edit;
|
||||
};
|
||||
|
||||
|
|
@ -64,7 +66,9 @@ function keyListener(event) {
|
|||
const ctrl = event.ctrlKey;
|
||||
const meta = event.metaKey;
|
||||
const ctrlMeta = ctrl || meta;
|
||||
const Key = CloudCmd.Key;
|
||||
const {
|
||||
Key
|
||||
} = CloudCmd;
|
||||
|
||||
if (!ctrlMeta || event.keyCode !== Key.S)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -11,13 +11,19 @@ const {FS} = require('../../common/cloudfunc');
|
|||
const {getIdBySrc} = require('../dom/load');
|
||||
const RESTful = require('../dom/rest');
|
||||
|
||||
const config = CloudCmd.config;
|
||||
const Buffer = DOM.Buffer;
|
||||
const {
|
||||
config,
|
||||
Key
|
||||
} = CloudCmd;
|
||||
|
||||
const {
|
||||
Buffer,
|
||||
Events,
|
||||
Dialog,
|
||||
Images
|
||||
} = DOM;
|
||||
|
||||
const Info = DOM.CurrentInfo;
|
||||
const Key = CloudCmd.Key;
|
||||
const Events = DOM.Events;
|
||||
const Dialog = DOM.Dialog;
|
||||
const Images = DOM.Images;
|
||||
const TITLE = 'Cloud Commander';
|
||||
const alertNoFiles = wrap(Dialog.alert.noFiles)(TITLE);
|
||||
const uploadTo = wrap(_uploadTo);
|
||||
|
|
@ -190,7 +196,9 @@ function isPath(x, y) {
|
|||
}
|
||||
|
||||
function beforeShow(callback, params) {
|
||||
const name = params.name;
|
||||
const {
|
||||
name
|
||||
} = params;
|
||||
let el = DOM.getCurrentByPosition({
|
||||
x: params.x,
|
||||
y: params.y
|
||||
|
|
@ -223,9 +231,11 @@ function _uploadTo(nameModule) {
|
|||
if (error)
|
||||
return;
|
||||
|
||||
const name = Info.name;
|
||||
const {
|
||||
name
|
||||
} = Info;
|
||||
const execFrom = CloudCmd.execFromModule;
|
||||
|
||||
|
||||
execFrom(nameModule, 'uploadFile', name, data);
|
||||
});
|
||||
|
||||
|
|
@ -241,7 +251,7 @@ function uploadFromCloud() {
|
|||
RESTful.write(path, data, (error) => {
|
||||
if (error)
|
||||
return;
|
||||
|
||||
|
||||
CloudCmd.refresh({currentName});
|
||||
});
|
||||
});
|
||||
|
|
@ -260,7 +270,7 @@ function download(type) {
|
|||
|
||||
if (!files.length)
|
||||
return alertNoFiles();
|
||||
|
||||
|
||||
files.forEach((file) => {
|
||||
const selected = DOM.isSelected(file);
|
||||
const isDir = DOM.isCurrentIsDir(file);
|
||||
|
|
@ -312,8 +322,11 @@ function getCurrentPosition() {
|
|||
}
|
||||
|
||||
function listener(event) {
|
||||
const F9 = Key.F9;
|
||||
const ESC = Key.ESC;
|
||||
const {
|
||||
F9,
|
||||
ESC
|
||||
} = Key;
|
||||
|
||||
const key = event.keyCode;
|
||||
const isBind = Key.isBind();
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,9 @@ module.exports = (currentName, names, removedNames) => {
|
|||
const i = names.indexOf(currentName);
|
||||
|
||||
const nextNames = notOneOf(names, removedNames);
|
||||
const length = nextNames.length;
|
||||
const {
|
||||
length
|
||||
} = nextNames;
|
||||
|
||||
if (nextNames[i])
|
||||
return nextNames[i];
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ function deleteSilent(files = DOM.getActiveFiles()) {
|
|||
const isCurrent = names.includes(currentName);
|
||||
|
||||
let name = isCurrent ? currentName : nextCurrentName;
|
||||
|
||||
|
||||
DOM.setCurrentByName(name);
|
||||
});
|
||||
});
|
||||
|
|
@ -348,7 +348,7 @@ function _processFiles(options, data) {
|
|||
|
||||
function go() {
|
||||
showLoad();
|
||||
|
||||
|
||||
files = {
|
||||
from,
|
||||
to,
|
||||
|
|
@ -390,9 +390,15 @@ function twopack(operation, type) {
|
|||
let fileFrom;
|
||||
let currentName = Info.name;
|
||||
|
||||
const Images = DOM.Images;
|
||||
const path = Info.path;
|
||||
const dirPath = Info.dirPath;
|
||||
const {
|
||||
Images
|
||||
} = DOM;
|
||||
|
||||
const {
|
||||
path,
|
||||
dirPath
|
||||
} = Info;
|
||||
|
||||
const activeFiles = DOM.getActiveFiles();
|
||||
const names = DOM.getFilenames(activeFiles);
|
||||
|
||||
|
|
|
|||
|
|
@ -17,15 +17,16 @@ const loadParallel = promisify(load.parallel);
|
|||
const TITLE = 'Terminal';
|
||||
|
||||
const {Dialog} = DOM;
|
||||
const {Key} = CloudCmd;
|
||||
const {
|
||||
Key,
|
||||
config
|
||||
} = CloudCmd;
|
||||
|
||||
CloudCmd.Terminal = exports;
|
||||
|
||||
let Loaded;
|
||||
let Terminal;
|
||||
|
||||
const {config} = CloudCmd;
|
||||
|
||||
const loadAll = async () => {
|
||||
const {
|
||||
prefix,
|
||||
|
|
|
|||
|
|
@ -40,7 +40,9 @@ const Name = 'View';
|
|||
CloudCmd[Name] = module.exports;
|
||||
|
||||
const Info = DOM.CurrentInfo;
|
||||
const Key = CloudCmd.Key;
|
||||
const {
|
||||
Key
|
||||
} = CloudCmd;
|
||||
const basename = (a) => a.split('/').pop();
|
||||
|
||||
let El;
|
||||
|
|
@ -313,7 +315,7 @@ function onOverlayClick(event) {
|
|||
x: event.clientX,
|
||||
y: event.clientY
|
||||
};
|
||||
|
||||
|
||||
setCurrentByPosition(position);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,12 @@
|
|||
const DOM = require('./dom');
|
||||
|
||||
const Info = DOM.CurrentInfo;
|
||||
const sort = CloudCmd.sort;
|
||||
const order = CloudCmd.order;
|
||||
|
||||
const {
|
||||
sort,
|
||||
order
|
||||
} = CloudCmd;
|
||||
|
||||
const position = DOM.getPanelPosition();
|
||||
|
||||
let sortPrevious = sort[position];
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@
|
|||
const rendy = require('rendy/legacy');
|
||||
const currify = require('currify/legacy');
|
||||
const store = require('fullstore/legacy');
|
||||
const encode = require('./entity').encode;
|
||||
const {
|
||||
encode
|
||||
} = require('./entity');
|
||||
const btoa = require('./btoa');
|
||||
|
||||
const getHeaderField = currify(_getHeaderField);
|
||||
|
|
@ -42,7 +44,9 @@ module.exports.getTitle = (options) => {
|
|||
options = options || {};
|
||||
|
||||
const path = options.path || Path();
|
||||
const name = options.name;
|
||||
const {
|
||||
name
|
||||
} = options;
|
||||
|
||||
const array = [
|
||||
name || NAME,
|
||||
|
|
@ -107,14 +111,20 @@ const getDataName = (name) => {
|
|||
*
|
||||
*/
|
||||
module.exports.buildFromJSON = (params) => {
|
||||
const prefix = params.prefix;
|
||||
const template = params.template;
|
||||
const {
|
||||
prefix,
|
||||
template
|
||||
} = params;
|
||||
|
||||
const templateFile = template.file;
|
||||
const templateLink = template.link;
|
||||
const json = params.data;
|
||||
|
||||
const path = encode(json.path);
|
||||
const files = json.files;
|
||||
|
||||
const {
|
||||
files
|
||||
} = json;
|
||||
|
||||
const sort = params.sort || 'name';
|
||||
const order = params.order || 'asc';
|
||||
|
|
@ -188,12 +198,14 @@ module.exports.buildFromJSON = (params) => {
|
|||
const name = encode(file.name);
|
||||
const link = prefix + FS + path + name;
|
||||
|
||||
const {type} = file;
|
||||
const {
|
||||
type,
|
||||
mode
|
||||
} = file;
|
||||
const size = getSize(file);
|
||||
|
||||
const date = file.date || '--.--.----';
|
||||
const owner = file.owner || 'root';
|
||||
const mode = file.mode;
|
||||
|
||||
const linkResult = rendy(templateLink, {
|
||||
link,
|
||||
|
|
|
|||
|
|
@ -31,7 +31,9 @@ const save = promisify(_save);
|
|||
|
||||
const formatMsg = currify((a, b) => CloudFunc.formatMsg(a, b));
|
||||
|
||||
const apiURL = CloudFunc.apiURL;
|
||||
const {
|
||||
apiURL
|
||||
} = CloudFunc;
|
||||
const changeEmitter = new Emitter();
|
||||
|
||||
const ConfigPath = path.join(DIR, 'json/config.json');
|
||||
|
|
@ -108,7 +110,7 @@ function listen(sock, auth) {
|
|||
.on('connection', (socket) => {
|
||||
if (!manage('auth'))
|
||||
return connection(socket);
|
||||
|
||||
|
||||
const reject = () => socket.emit('reject');
|
||||
socket.on('auth', auth(connectionWraped(socket), reject));
|
||||
});
|
||||
|
|
@ -145,7 +147,7 @@ function middle(req, res, next) {
|
|||
|
||||
if (req.url !== `${apiURL}/config`)
|
||||
return next();
|
||||
|
||||
|
||||
switch(req.method) {
|
||||
case 'GET':
|
||||
get(req, res, next);
|
||||
|
|
@ -156,7 +158,7 @@ function middle(req, res, next) {
|
|||
return res
|
||||
.status(404)
|
||||
.send('Config is disabled');
|
||||
|
||||
|
||||
patch(req, res);
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,15 +8,16 @@ const omit = require('object.omit');
|
|||
const config = require('../config');
|
||||
const log = require('./log');
|
||||
|
||||
const exportStr = log.exportStr;
|
||||
const connectedStr = log.connectedStr;
|
||||
const disconnectedStr = log.disconnectedStr;
|
||||
const authTryStr = log.authTryStr;
|
||||
|
||||
const makeColor = log.makeColor;
|
||||
const getMessage = log.getMessage;
|
||||
const getDescription = log.getDescription;
|
||||
const logWraped = log.logWraped;
|
||||
const {
|
||||
exportStr,
|
||||
connectedStr,
|
||||
disconnectedStr,
|
||||
authTryStr,
|
||||
makeColor,
|
||||
getMessage,
|
||||
getDescription,
|
||||
logWraped
|
||||
} = log;
|
||||
|
||||
const omitList = [
|
||||
'auth',
|
||||
|
|
@ -66,10 +67,15 @@ const push = currify((socket, key, value) => {
|
|||
});
|
||||
|
||||
function getHost(socket) {
|
||||
const remoteAddress = socket.request.connection.remoteAddress;
|
||||
const name = socket.handshake.query.name;
|
||||
const port = socket.handshake.query.port;
|
||||
const color = socket.handshake.query.color;
|
||||
const {
|
||||
remoteAddress
|
||||
} = socket.request.connection;
|
||||
|
||||
const {
|
||||
name,
|
||||
port,
|
||||
color
|
||||
} = socket.handshake.query;
|
||||
|
||||
if (!name)
|
||||
return `${remoteAddress}:${port}`;
|
||||
|
|
|
|||
|
|
@ -11,17 +11,18 @@ const forEachKey = currify(require('for-each-key'));
|
|||
const config = require('../config');
|
||||
const log = require('./log');
|
||||
|
||||
const importStr = log.importStr;
|
||||
const connectedStr = log.connectedStr;
|
||||
const disconnectedStr = log.disconnectedStr;
|
||||
const tokenRejectedStr = log.tokenRejectedStr;
|
||||
const authTryStr = log.authTryStr;
|
||||
|
||||
const makeColor = log.makeColor;
|
||||
const stringToRGB = log.stringToRGB;
|
||||
const getMessage = log.getMessage;
|
||||
const getDescription = log.getDescription;
|
||||
const logWraped = log.logWraped;
|
||||
const {
|
||||
importStr,
|
||||
connectedStr,
|
||||
disconnectedStr,
|
||||
tokenRejectedStr,
|
||||
authTryStr,
|
||||
makeColor,
|
||||
stringToRGB,
|
||||
getMessage,
|
||||
getDescription,
|
||||
logWraped
|
||||
} = log;
|
||||
|
||||
const equal = (a, b) => `${a}=${b}`;
|
||||
const append = currify((obj, a, b) => obj.value += b && equal(a, b) + '&');
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
'use strict';
|
||||
|
||||
const env = process.env;
|
||||
const {
|
||||
env
|
||||
} = process;
|
||||
const up = (a) => a.toUpperCase();
|
||||
|
||||
module.exports = parse;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ const net = require('net');
|
|||
const repl = require('repl');
|
||||
|
||||
module.exports = net.createServer((socket) => {
|
||||
const pid = process.pid;
|
||||
const {
|
||||
pid
|
||||
} = process;
|
||||
const addr = socket.remoteAddress;
|
||||
const port = socket.remotePort;
|
||||
|
||||
|
|
@ -15,7 +17,7 @@ module.exports = net.createServer((socket) => {
|
|||
terminal: true,
|
||||
useGlobal: false
|
||||
});
|
||||
|
||||
|
||||
r.on('exit', () => {
|
||||
socket.end();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -84,7 +84,9 @@ function sendData(params, callback) {
|
|||
if (isMD)
|
||||
return markdown(p.name, p.request, callback);
|
||||
|
||||
const method = p.request.method;
|
||||
const {
|
||||
method
|
||||
} = p.request;
|
||||
|
||||
switch(method) {
|
||||
case 'GET':
|
||||
|
|
@ -179,7 +181,9 @@ function onPUT(name, body, callback) {
|
|||
|
||||
const from = root(files.from);
|
||||
const to = root(files.to);
|
||||
const names = files.names;
|
||||
const {
|
||||
names
|
||||
} = files;
|
||||
|
||||
if (!names)
|
||||
return fs.rename(from, to, fn);
|
||||
|
|
@ -193,7 +197,7 @@ function onPUT(name, body, callback) {
|
|||
|
||||
if (isRootAll([files.to, files.from]))
|
||||
return callback(getWin32RootMsg());
|
||||
|
||||
|
||||
files.from = root(files.from);
|
||||
files.to = root(files.to);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,15 @@
|
|||
|
||||
const format = require('format-io');
|
||||
|
||||
const version = require('../../package').version;
|
||||
const {
|
||||
version
|
||||
} = require('../../package');
|
||||
const config = require('../config');
|
||||
|
||||
const getMemory = () => {
|
||||
const rss = process.memoryUsage().rss;
|
||||
const {
|
||||
rss
|
||||
} = process.memoryUsage();
|
||||
return format.size(rss);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -113,9 +113,13 @@ function indexProcessing(options) {
|
|||
const noConfig = !config('configDialog');
|
||||
const noConsole = !config('console');
|
||||
const noTerminal = !config('terminal');
|
||||
const panel = options.panel;
|
||||
const {
|
||||
panel
|
||||
} = options;
|
||||
|
||||
let data = options.data;
|
||||
let {
|
||||
data
|
||||
} = options;
|
||||
|
||||
if (noKeysPanel)
|
||||
data = hideKeysPanel(data);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue