mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-26 09:24:07 +00:00
Compare commits
2 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d83958edea | ||
|
|
7603fe2bdd |
6 changed files with 837 additions and 803 deletions
|
|
@ -1,3 +1,9 @@
|
||||||
|
2021.01.18, v15.3.2
|
||||||
|
|
||||||
|
fix:
|
||||||
|
- (client) dom: goToDirectory
|
||||||
|
|
||||||
|
|
||||||
2021.01.17, v15.3.1
|
2021.01.17, v15.3.1
|
||||||
|
|
||||||
fix:
|
fix:
|
||||||
|
|
|
||||||
2
HELP.md
2
HELP.md
|
|
@ -1,4 +1,4 @@
|
||||||
# Cloud Commander v15.3.1
|
# Cloud Commander v15.3.2
|
||||||
|
|
||||||
### [Main][MainURL] [Blog][BlogURL] Live(![Heroku][Heroku_LIVE_IMG] [Heroku][HerokuURL])
|
### [Main][MainURL] [Blog][BlogURL] Live(![Heroku][Heroku_LIVE_IMG] [Heroku][HerokuURL])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# Cloud Commander v15.3.1 [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Codacy][CodacyIMG]][CodacyURL] [![Gitter][GitterIMGURL]][GitterURL]
|
# Cloud Commander v15.3.2 [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Codacy][CodacyIMG]][CodacyURL] [![Gitter][GitterIMGURL]][GitterURL]
|
||||||
|
|
||||||
### [Main][MainURL] [Blog][BlogURL] Live([Heroku][HerokuURL])
|
### [Main][MainURL] [Blog][BlogURL] Live([Heroku][HerokuURL])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,15 @@ const renameCurrent = require('./operations/rename-current');
|
||||||
const CurrentFile = require('./current-file');
|
const CurrentFile = require('./current-file');
|
||||||
const DOMTree = require('./dom-tree');
|
const DOMTree = require('./dom-tree');
|
||||||
|
|
||||||
|
const Cmd = module.exports;
|
||||||
const DOM = {
|
const DOM = {
|
||||||
...DOMTree,
|
...DOMTree,
|
||||||
...CurrentFile,
|
...CurrentFile,
|
||||||
...new CmdProto(),
|
...Cmd,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const CurrentInfo = {};
|
||||||
|
|
||||||
DOM.Images = Images;
|
DOM.Images = Images;
|
||||||
DOM.load = load;
|
DOM.load = load;
|
||||||
DOM.Files = Files;
|
DOM.Files = Files;
|
||||||
|
|
@ -32,6 +35,7 @@ DOM.RESTful = RESTful;
|
||||||
DOM.IO = IO;
|
DOM.IO = IO;
|
||||||
DOM.Storage = Storage;
|
DOM.Storage = Storage;
|
||||||
DOM.Dialog = Dialog;
|
DOM.Dialog = Dialog;
|
||||||
|
DOM.CurrentInfo = CurrentInfo;
|
||||||
|
|
||||||
module.exports = DOM;
|
module.exports = DOM;
|
||||||
|
|
||||||
|
|
@ -42,22 +46,18 @@ DOM.Events = require('./events');
|
||||||
const loadRemote = require('./load-remote');
|
const loadRemote = require('./load-remote');
|
||||||
const selectByPattern = require('./select-by-pattern');
|
const selectByPattern = require('./select-by-pattern');
|
||||||
|
|
||||||
function CmdProto() {
|
|
||||||
const CurrentInfo = {};
|
|
||||||
|
|
||||||
const Cmd = this;
|
|
||||||
const SELECTED_FILE = 'selected-file';
|
const SELECTED_FILE = 'selected-file';
|
||||||
const TabPanel = {
|
const TabPanel = {
|
||||||
'js-left' : null,
|
'js-left' : null,
|
||||||
'js-right' : null,
|
'js-right' : null,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.loadRemote = (name, options, callback) => {
|
module.exports.loadRemote = (name, options, callback) => {
|
||||||
loadRemote(name, options, callback);
|
loadRemote(name, options, callback);
|
||||||
return DOM;
|
return DOM;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.loadSocket = function(callback) {
|
module.exports.loadSocket = (callback) => {
|
||||||
DOM.loadRemote('socket', {
|
DOM.loadRemote('socket', {
|
||||||
name : 'io',
|
name : 'io',
|
||||||
}, callback);
|
}, callback);
|
||||||
|
|
@ -69,7 +69,7 @@ function CmdProto() {
|
||||||
* create new folder
|
* create new folder
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
this.promptNewDir = async function() {
|
module.exports.promptNewDir = async function() {
|
||||||
await promptNew('directory');
|
await promptNew('directory');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -79,7 +79,7 @@ function CmdProto() {
|
||||||
* @typeName
|
* @typeName
|
||||||
* @type
|
* @type
|
||||||
*/
|
*/
|
||||||
this.promptNewFile = async () => {
|
module.exports.promptNewFile = async () => {
|
||||||
await promptNew('file');
|
await promptNew('file');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -117,7 +117,7 @@ function CmdProto() {
|
||||||
/**
|
/**
|
||||||
* get current direcotory name
|
* get current direcotory name
|
||||||
*/
|
*/
|
||||||
this.getCurrentDirName = () => {
|
module.exports.getCurrentDirName = () => {
|
||||||
const href = DOM.getCurrentDirPath()
|
const href = DOM.getCurrentDirPath()
|
||||||
.replace(/\/$/, '');
|
.replace(/\/$/, '');
|
||||||
|
|
||||||
|
|
@ -130,7 +130,7 @@ function CmdProto() {
|
||||||
/**
|
/**
|
||||||
* get current direcotory path
|
* get current direcotory path
|
||||||
*/
|
*/
|
||||||
this.getParentDirPath = (panel) => {
|
module.exports.getParentDirPath = (panel) => {
|
||||||
const path = DOM.getCurrentDirPath(panel);
|
const path = DOM.getCurrentDirPath(panel);
|
||||||
const dirName = DOM.getCurrentDirName() + '/';
|
const dirName = DOM.getCurrentDirName() + '/';
|
||||||
const index = path.lastIndexOf(dirName);
|
const index = path.lastIndexOf(dirName);
|
||||||
|
|
@ -144,7 +144,7 @@ function CmdProto() {
|
||||||
/**
|
/**
|
||||||
* get not current direcotory path
|
* get not current direcotory path
|
||||||
*/
|
*/
|
||||||
this.getNotCurrentDirPath = () => {
|
module.exports.getNotCurrentDirPath = () => {
|
||||||
const panel = DOM.getPanel({active: false});
|
const panel = DOM.getPanel({active: false});
|
||||||
const path = DOM.getCurrentDirPath(panel);
|
const path = DOM.getCurrentDirPath(panel);
|
||||||
|
|
||||||
|
|
@ -154,7 +154,7 @@ function CmdProto() {
|
||||||
/**
|
/**
|
||||||
* get current file by name
|
* get current file by name
|
||||||
*/
|
*/
|
||||||
this.getCurrentByName = (name, panel = CurrentInfo.panel) => {
|
module.exports.getCurrentByName = (name, panel = CurrentInfo.panel) => {
|
||||||
const dataName = 'js-file-' + btoa(encodeURI(name));
|
const dataName = 'js-file-' + btoa(encodeURI(name));
|
||||||
const element = DOM.getByDataName(dataName, panel);
|
const element = DOM.getByDataName(dataName, panel);
|
||||||
|
|
||||||
|
|
@ -166,7 +166,7 @@ function CmdProto() {
|
||||||
*
|
*
|
||||||
* @currentFile
|
* @currentFile
|
||||||
*/
|
*/
|
||||||
this.getSelectedFiles = () => {
|
module.exports.getSelectedFiles = () => {
|
||||||
const panel = DOM.getPanel();
|
const panel = DOM.getPanel();
|
||||||
const selected = DOM.getByClassAll(SELECTED_FILE, panel);
|
const selected = DOM.getByClassAll(SELECTED_FILE, panel);
|
||||||
|
|
||||||
|
|
@ -176,7 +176,7 @@ function CmdProto() {
|
||||||
/*
|
/*
|
||||||
* unselect all files
|
* unselect all files
|
||||||
*/
|
*/
|
||||||
this.unselectFiles = (files) => {
|
module.exports.unselectFiles = (files) => {
|
||||||
files = files || DOM.getSelectedFiles();
|
files = files || DOM.getSelectedFiles();
|
||||||
|
|
||||||
Array.from(files).forEach(DOM.toggleSelectedFile);
|
Array.from(files).forEach(DOM.toggleSelectedFile);
|
||||||
|
|
@ -187,7 +187,7 @@ function CmdProto() {
|
||||||
*
|
*
|
||||||
* @currentFile
|
* @currentFile
|
||||||
*/
|
*/
|
||||||
this.getActiveFiles = () => {
|
module.exports.getActiveFiles = () => {
|
||||||
const current = DOM.getCurrentFile();
|
const current = DOM.getCurrentFile();
|
||||||
const files = DOM.getSelectedFiles();
|
const files = DOM.getSelectedFiles();
|
||||||
const name = DOM.getCurrentName(current);
|
const name = DOM.getCurrentName(current);
|
||||||
|
|
@ -198,7 +198,7 @@ function CmdProto() {
|
||||||
return files;
|
return files;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getCurrentDate = (currentFile) => {
|
module.exports.getCurrentDate = (currentFile) => {
|
||||||
const current = currentFile || DOM.getCurrentFile();
|
const current = currentFile || DOM.getCurrentFile();
|
||||||
const date = DOM
|
const date = DOM
|
||||||
.getByDataName('js-date', current)
|
.getByDataName('js-date', current)
|
||||||
|
|
@ -211,7 +211,7 @@ function CmdProto() {
|
||||||
* get size
|
* get size
|
||||||
* @currentFile
|
* @currentFile
|
||||||
*/
|
*/
|
||||||
this.getCurrentSize = (currentFile) => {
|
module.exports.getCurrentSize = (currentFile) => {
|
||||||
const current = currentFile || DOM.getCurrentFile();
|
const current = currentFile || DOM.getCurrentFile();
|
||||||
/* если это папка - возвращаем слово dir вместо размера*/
|
/* если это папка - возвращаем слово dir вместо размера*/
|
||||||
const size = DOM.getByDataName('js-size', current)
|
const size = DOM.getByDataName('js-size', current)
|
||||||
|
|
@ -225,7 +225,7 @@ function CmdProto() {
|
||||||
* get size
|
* get size
|
||||||
* @currentFile
|
* @currentFile
|
||||||
*/
|
*/
|
||||||
this.loadCurrentSize = async (currentFile) => {
|
module.exports.loadCurrentSize = async (currentFile) => {
|
||||||
const current = currentFile || DOM.getCurrentFile();
|
const current = currentFile || DOM.getCurrentFile();
|
||||||
const query = '?size';
|
const query = '?size';
|
||||||
const link = DOM.getCurrentPath(current);
|
const link = DOM.getCurrentPath(current);
|
||||||
|
|
@ -248,7 +248,7 @@ function CmdProto() {
|
||||||
* @callback
|
* @callback
|
||||||
* @currentFile
|
* @currentFile
|
||||||
*/
|
*/
|
||||||
this.loadCurrentHash = async (currentFile) => {
|
module.exports.loadCurrentHash = async (currentFile) => {
|
||||||
const current = currentFile || DOM.getCurrentFile();
|
const current = currentFile || DOM.getCurrentFile();
|
||||||
const query = '?hash';
|
const query = '?hash';
|
||||||
const link = DOM.getCurrentPath(current);
|
const link = DOM.getCurrentPath(current);
|
||||||
|
|
@ -262,7 +262,7 @@ function CmdProto() {
|
||||||
* @callback
|
* @callback
|
||||||
* @currentFile
|
* @currentFile
|
||||||
*/
|
*/
|
||||||
this.loadCurrentTime = async (currentFile) => {
|
module.exports.loadCurrentTime = async (currentFile) => {
|
||||||
const current = currentFile || DOM.getCurrentFile();
|
const current = currentFile || DOM.getCurrentFile();
|
||||||
const query = '?time';
|
const query = '?time';
|
||||||
const link = DOM.getCurrentPath(current);
|
const link = DOM.getCurrentPath(current);
|
||||||
|
|
@ -275,7 +275,7 @@ function CmdProto() {
|
||||||
* set size
|
* set size
|
||||||
* @currentFile
|
* @currentFile
|
||||||
*/
|
*/
|
||||||
this.setCurrentSize = (size, currentFile) => {
|
module.exports.setCurrentSize = (size, currentFile) => {
|
||||||
const current = currentFile || DOM.getCurrentFile();
|
const current = currentFile || DOM.getCurrentFile();
|
||||||
const sizeElement = DOM.getByDataName('js-size', current);
|
const sizeElement = DOM.getByDataName('js-size', current);
|
||||||
|
|
||||||
|
|
@ -285,7 +285,7 @@ function CmdProto() {
|
||||||
/**
|
/**
|
||||||
* @currentFile
|
* @currentFile
|
||||||
*/
|
*/
|
||||||
this.getCurrentMode = (currentFile) => {
|
module.exports.getCurrentMode = (currentFile) => {
|
||||||
const current = currentFile || DOM.getCurrentFile();
|
const current = currentFile || DOM.getCurrentFile();
|
||||||
const mode = DOM.getByDataName('js-mode', current);
|
const mode = DOM.getByDataName('js-mode', current);
|
||||||
|
|
||||||
|
|
@ -295,7 +295,7 @@ function CmdProto() {
|
||||||
/**
|
/**
|
||||||
* @currentFile
|
* @currentFile
|
||||||
*/
|
*/
|
||||||
this.getCurrentOwner = (currentFile) => {
|
module.exports.getCurrentOwner = (currentFile) => {
|
||||||
const current = currentFile || DOM.getCurrentFile();
|
const current = currentFile || DOM.getCurrentFile();
|
||||||
const owner = DOM.getByDataName('js-owner', current);
|
const owner = DOM.getByDataName('js-owner', current);
|
||||||
|
|
||||||
|
|
@ -310,7 +310,7 @@ function CmdProto() {
|
||||||
* @param callback
|
* @param callback
|
||||||
* @param currentFile
|
* @param currentFile
|
||||||
*/
|
*/
|
||||||
this.getCurrentData = callbackify(mixArgs(async (callback, currentFile) => {
|
module.exports.getCurrentData = callbackify(mixArgs(async (callback, currentFile) => {
|
||||||
const {Dialog} = DOM;
|
const {Dialog} = DOM;
|
||||||
const Info = DOM.CurrentInfo;
|
const Info = DOM.CurrentInfo;
|
||||||
const current = currentFile || DOM.getCurrentFile();
|
const current = currentFile || DOM.getCurrentFile();
|
||||||
|
|
@ -353,7 +353,7 @@ function CmdProto() {
|
||||||
/**
|
/**
|
||||||
* unified way to get RefreshButton
|
* unified way to get RefreshButton
|
||||||
*/
|
*/
|
||||||
this.getRefreshButton = (panel = DOM.getPanel()) => {
|
module.exports.getRefreshButton = (panel = DOM.getPanel()) => {
|
||||||
return DOM.getByDataName('js-refresh', panel);
|
return DOM.getByDataName('js-refresh', panel);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -361,7 +361,7 @@ function CmdProto() {
|
||||||
* select current file
|
* select current file
|
||||||
* @param currentFile
|
* @param currentFile
|
||||||
*/
|
*/
|
||||||
this.selectFile = (currentFile) => {
|
module.exports.selectFile = (currentFile) => {
|
||||||
const current = currentFile || DOM.getCurrentFile();
|
const current = currentFile || DOM.getCurrentFile();
|
||||||
|
|
||||||
current.classList.add(SELECTED_FILE);
|
current.classList.add(SELECTED_FILE);
|
||||||
|
|
@ -369,7 +369,7 @@ function CmdProto() {
|
||||||
return Cmd;
|
return Cmd;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.unselectFile = (currentFile) => {
|
module.exports.unselectFile = (currentFile) => {
|
||||||
const current = currentFile || DOM.getCurrentFile();
|
const current = currentFile || DOM.getCurrentFile();
|
||||||
|
|
||||||
current.classList.remove(SELECTED_FILE);
|
current.classList.remove(SELECTED_FILE);
|
||||||
|
|
@ -377,7 +377,7 @@ function CmdProto() {
|
||||||
return Cmd;
|
return Cmd;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.toggleSelectedFile = (currentFile) => {
|
module.exports.toggleSelectedFile = (currentFile) => {
|
||||||
const current = currentFile || DOM.getCurrentFile();
|
const current = currentFile || DOM.getCurrentFile();
|
||||||
const name = DOM.getCurrentName(current);
|
const name = DOM.getCurrentName(current);
|
||||||
|
|
||||||
|
|
@ -389,19 +389,19 @@ function CmdProto() {
|
||||||
return Cmd;
|
return Cmd;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.toggleAllSelectedFiles = () => {
|
module.exports.toggleAllSelectedFiles = () => {
|
||||||
DOM.getAllFiles().map(DOM.toggleSelectedFile);
|
DOM.getAllFiles().map(DOM.toggleSelectedFile);
|
||||||
|
|
||||||
return Cmd;
|
return Cmd;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.selectAllFiles = () => {
|
module.exports.selectAllFiles = () => {
|
||||||
DOM.getAllFiles().map(DOM.selectFile);
|
DOM.getAllFiles().map(DOM.selectFile);
|
||||||
|
|
||||||
return Cmd;
|
return Cmd;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getAllFiles = () => {
|
module.exports.getAllFiles = () => {
|
||||||
const panel = DOM.getPanel();
|
const panel = DOM.getPanel();
|
||||||
const files = DOM.getFiles(panel);
|
const files = DOM.getFiles(panel);
|
||||||
const name = DOM.getCurrentName(files[0]);
|
const name = DOM.getCurrentName(files[0]);
|
||||||
|
|
@ -415,7 +415,7 @@ function CmdProto() {
|
||||||
/**
|
/**
|
||||||
* open dialog with expand selection
|
* open dialog with expand selection
|
||||||
*/
|
*/
|
||||||
this.expandSelection = () => {
|
module.exports.expandSelection = () => {
|
||||||
const msg = 'expand';
|
const msg = 'expand';
|
||||||
const {files} = CurrentInfo;
|
const {files} = CurrentInfo;
|
||||||
|
|
||||||
|
|
@ -425,7 +425,7 @@ function CmdProto() {
|
||||||
/**
|
/**
|
||||||
* open dialog with shrink selection
|
* open dialog with shrink selection
|
||||||
*/
|
*/
|
||||||
this.shrinkSelection = () => {
|
module.exports.shrinkSelection = () => {
|
||||||
const msg = 'shrink';
|
const msg = 'shrink';
|
||||||
const {files} = CurrentInfo;
|
const {files} = CurrentInfo;
|
||||||
|
|
||||||
|
|
@ -435,7 +435,7 @@ function CmdProto() {
|
||||||
/**
|
/**
|
||||||
* setting history wrapper
|
* setting history wrapper
|
||||||
*/
|
*/
|
||||||
this.setHistory = (data, title, url) => {
|
module.exports.setHistory = (data, title, url) => {
|
||||||
const ret = window.history;
|
const ret = window.history;
|
||||||
const {prefix} = CloudCmd;
|
const {prefix} = CloudCmd;
|
||||||
|
|
||||||
|
|
@ -452,7 +452,7 @@ function CmdProto() {
|
||||||
*
|
*
|
||||||
* @param currentFile
|
* @param currentFile
|
||||||
*/
|
*/
|
||||||
this.isSelected = (selected) => {
|
module.exports.isSelected = (selected) => {
|
||||||
if (!selected)
|
if (!selected)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -464,14 +464,14 @@ function CmdProto() {
|
||||||
*
|
*
|
||||||
* @param currentFile - current file by default
|
* @param currentFile - current file by default
|
||||||
*/
|
*/
|
||||||
this.getCurrentLink = (currentFile) => {
|
module.exports.getCurrentLink = (currentFile) => {
|
||||||
const current = currentFile || DOM.getCurrentFile();
|
const current = currentFile || DOM.getCurrentFile();
|
||||||
const link = DOM.getByTag('a', current);
|
const link = DOM.getByTag('a', current);
|
||||||
|
|
||||||
return link[0];
|
return link[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getFilenames = (files) => {
|
module.exports.getFilenames = (files) => {
|
||||||
if (!files)
|
if (!files)
|
||||||
throw Error('AllFiles could not be empty');
|
throw Error('AllFiles could not be empty');
|
||||||
|
|
||||||
|
|
@ -493,7 +493,7 @@ function CmdProto() {
|
||||||
/**
|
/**
|
||||||
* check storage hash
|
* check storage hash
|
||||||
*/
|
*/
|
||||||
this.checkStorageHash = async (name) => {
|
module.exports.checkStorageHash = async (name) => {
|
||||||
const nameHash = name + '-hash';
|
const nameHash = name + '-hash';
|
||||||
|
|
||||||
if (typeof name !== 'string')
|
if (typeof name !== 'string')
|
||||||
|
|
@ -518,7 +518,7 @@ function CmdProto() {
|
||||||
* @param hash
|
* @param hash
|
||||||
* @param callback
|
* @param callback
|
||||||
*/
|
*/
|
||||||
this.saveDataToStorage = async (name, data, hash) => {
|
module.exports.saveDataToStorage = async (name, data, hash) => {
|
||||||
const isDir = DOM.isCurrentIsDir();
|
const isDir = DOM.isCurrentIsDir();
|
||||||
|
|
||||||
if (isDir)
|
if (isDir)
|
||||||
|
|
@ -535,11 +535,11 @@ function CmdProto() {
|
||||||
return hash;
|
return hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getFM = () => {
|
module.exports.getFM = () => {
|
||||||
return DOM.getPanel().parentElement;
|
return DOM.getPanel().parentElement;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getPanelPosition = (panel) => {
|
module.exports.getPanelPosition = (panel) => {
|
||||||
panel = panel || DOM.getPanel();
|
panel = panel || DOM.getPanel();
|
||||||
|
|
||||||
return panel.dataset.name.replace('js-', '');
|
return panel.dataset.name.replace('js-', '');
|
||||||
|
|
@ -548,7 +548,7 @@ function CmdProto() {
|
||||||
/** function getting panel active, or passive
|
/** function getting panel active, or passive
|
||||||
* @param options = {active: true}
|
* @param options = {active: true}
|
||||||
*/
|
*/
|
||||||
this.getPanel = (options) => {
|
module.exports.getPanel = (options) => {
|
||||||
let files;
|
let files;
|
||||||
let panel;
|
let panel;
|
||||||
let isLeft;
|
let isLeft;
|
||||||
|
|
@ -583,7 +583,7 @@ function CmdProto() {
|
||||||
return panel;
|
return panel;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getFiles = (element) => {
|
module.exports.getFiles = (element) => {
|
||||||
const files = DOM.getByDataName('js-files', element);
|
const files = DOM.getByDataName('js-files', element);
|
||||||
return files.children || [];
|
return files.children || [];
|
||||||
};
|
};
|
||||||
|
|
@ -591,7 +591,7 @@ function CmdProto() {
|
||||||
/**
|
/**
|
||||||
* shows panel right or left (or active)
|
* shows panel right or left (or active)
|
||||||
*/
|
*/
|
||||||
this.showPanel = (active) => {
|
module.exports.showPanel = (active) => {
|
||||||
const panel = DOM.getPanel({active});
|
const panel = DOM.getPanel({active});
|
||||||
|
|
||||||
if (!panel)
|
if (!panel)
|
||||||
|
|
@ -605,7 +605,7 @@ function CmdProto() {
|
||||||
/**
|
/**
|
||||||
* hides panel right or left (or active)
|
* hides panel right or left (or active)
|
||||||
*/
|
*/
|
||||||
this.hidePanel = (active) => {
|
module.exports.hidePanel = (active) => {
|
||||||
const panel = DOM.getPanel({
|
const panel = DOM.getPanel({
|
||||||
active,
|
active,
|
||||||
});
|
});
|
||||||
|
|
@ -621,7 +621,7 @@ function CmdProto() {
|
||||||
* @param pChild
|
* @param pChild
|
||||||
* @param element
|
* @param element
|
||||||
*/
|
*/
|
||||||
this.remove = (child, element) => {
|
module.exports.remove = (child, element) => {
|
||||||
const parent = element || document.body;
|
const parent = element || document.body;
|
||||||
|
|
||||||
parent.removeChild(child);
|
parent.removeChild(child);
|
||||||
|
|
@ -634,7 +634,7 @@ function CmdProto() {
|
||||||
* @param current
|
* @param current
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
this.deleteCurrent = (current) => {
|
module.exports.deleteCurrent = (current) => {
|
||||||
if (!current)
|
if (!current)
|
||||||
DOM.getCurrentFile();
|
DOM.getCurrentFile();
|
||||||
|
|
||||||
|
|
@ -654,7 +654,7 @@ function CmdProto() {
|
||||||
* remove selected files from file table
|
* remove selected files from file table
|
||||||
* @Selected
|
* @Selected
|
||||||
*/
|
*/
|
||||||
this.deleteSelected = (selected) => {
|
module.exports.deleteSelected = (selected) => {
|
||||||
selected = selected || DOM.getSelectedFiles();
|
selected = selected || DOM.getSelectedFiles();
|
||||||
|
|
||||||
if (!selected)
|
if (!selected)
|
||||||
|
|
@ -668,7 +668,7 @@ function CmdProto() {
|
||||||
*
|
*
|
||||||
* @currentFile
|
* @currentFile
|
||||||
*/
|
*/
|
||||||
this.renameCurrent = renameCurrent;
|
module.exports.renameCurrent = renameCurrent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* unified way to scrollIntoViewIfNeeded
|
* unified way to scrollIntoViewIfNeeded
|
||||||
|
|
@ -676,7 +676,7 @@ function CmdProto() {
|
||||||
* @param element
|
* @param element
|
||||||
* @param center - to scroll as small as possible param should be false
|
* @param center - to scroll as small as possible param should be false
|
||||||
*/
|
*/
|
||||||
this.scrollIntoViewIfNeeded = function(element, center = false) {
|
module.exports.scrollIntoViewIfNeeded = (element, center = false) => {
|
||||||
if (!element || !element.scrollIntoViewIfNeeded)
|
if (!element || !element.scrollIntoViewIfNeeded)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -684,7 +684,7 @@ function CmdProto() {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* scroll on one page */
|
/* scroll on one page */
|
||||||
this.scrollByPages = (element, pPages) => {
|
module.exports.scrollByPages = (element, pPages) => {
|
||||||
const ret = element?.scrollByPages && pPages;
|
const ret = element?.scrollByPages && pPages;
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
|
|
@ -693,7 +693,7 @@ function CmdProto() {
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.changePanel = () => {
|
module.exports.changePanel = () => {
|
||||||
const Info = CurrentInfo;
|
const Info = CurrentInfo;
|
||||||
let panel = DOM.getPanel();
|
let panel = DOM.getPanel();
|
||||||
|
|
||||||
|
|
@ -741,14 +741,14 @@ function CmdProto() {
|
||||||
return DOM;
|
return DOM;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getPackerExt = (type) => {
|
module.exports.getPackerExt = (type) => {
|
||||||
if (type === 'zip')
|
if (type === 'zip')
|
||||||
return '.zip';
|
return '.zip';
|
||||||
|
|
||||||
return '.tar.gz';
|
return '.tar.gz';
|
||||||
};
|
};
|
||||||
|
|
||||||
this.goToDirectory = async () => {
|
module.exports.goToDirectory = async () => {
|
||||||
const msg = 'Go to directory:';
|
const msg = 'Go to directory:';
|
||||||
const {Dialog} = DOM;
|
const {Dialog} = DOM;
|
||||||
const {dirPath} = CurrentInfo;
|
const {dirPath} = CurrentInfo;
|
||||||
|
|
@ -756,7 +756,7 @@ function CmdProto() {
|
||||||
const [
|
const [
|
||||||
cancel,
|
cancel,
|
||||||
path = dirPath,
|
path = dirPath,
|
||||||
] = await Dialog.prompt(msg, path);
|
] = await Dialog.prompt(msg, dirPath);
|
||||||
|
|
||||||
if (cancel)
|
if (cancel)
|
||||||
return;
|
return;
|
||||||
|
|
@ -766,7 +766,7 @@ function CmdProto() {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.duplicatePanel = async () => {
|
module.exports.duplicatePanel = async () => {
|
||||||
const Info = CurrentInfo;
|
const Info = CurrentInfo;
|
||||||
const {isDir} = Info;
|
const {isDir} = Info;
|
||||||
const panel = Info.panelPassive;
|
const panel = Info.panelPassive;
|
||||||
|
|
@ -788,7 +788,7 @@ function CmdProto() {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.swapPanels = async () => {
|
module.exports.swapPanels = async () => {
|
||||||
const Info = CurrentInfo;
|
const Info = CurrentInfo;
|
||||||
const {
|
const {
|
||||||
panel,
|
panel,
|
||||||
|
|
@ -823,9 +823,9 @@ function CmdProto() {
|
||||||
DOM.setCurrentFile(el);
|
DOM.setCurrentFile(el);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.CurrentInfo = CurrentInfo;
|
module.exports.CurrentInfo = CurrentInfo;
|
||||||
|
|
||||||
this.updateCurrentInfo = (currentFile) => {
|
module.exports.updateCurrentInfo = (currentFile) => {
|
||||||
const info = DOM.CurrentInfo;
|
const info = DOM.CurrentInfo;
|
||||||
const current = currentFile || DOM.getCurrentFile();
|
const current = currentFile || DOM.getCurrentFile();
|
||||||
const files = current.parentElement;
|
const files = current.parentElement;
|
||||||
|
|
@ -864,5 +864,3 @@ function CmdProto() {
|
||||||
info.panel.getAttribute('data-name') ===
|
info.panel.getAttribute('data-name') ===
|
||||||
info.panelPassive.getAttribute('data-name');
|
info.panelPassive.getAttribute('data-name');
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
||||||
30
client/dom/index.spec.js
Normal file
30
client/dom/index.spec.js
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
require('css-modules-require-hook');
|
||||||
|
|
||||||
|
const {test, stub} = require('supertape');
|
||||||
|
const mockRequire = require('mock-require');
|
||||||
|
const {reRequire} = mockRequire;
|
||||||
|
|
||||||
|
global.CloudCmd = {};
|
||||||
|
|
||||||
|
test('cloudcmd: client: dom: goToDirectory', async (t) => {
|
||||||
|
const path = '';
|
||||||
|
const {CloudCmd} = global;
|
||||||
|
const loadDir = stub();
|
||||||
|
const prompt = stub().returns([null, path]);
|
||||||
|
|
||||||
|
CloudCmd.loadDir = loadDir;
|
||||||
|
|
||||||
|
mockRequire('./dialog', {
|
||||||
|
prompt,
|
||||||
|
});
|
||||||
|
|
||||||
|
const {goToDirectory} = reRequire('.');
|
||||||
|
|
||||||
|
await goToDirectory();
|
||||||
|
|
||||||
|
t.calledWith(loadDir, [{path}]);
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "cloudcmd",
|
"name": "cloudcmd",
|
||||||
"version": "15.3.1",
|
"version": "15.3.2",
|
||||||
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
||||||
"description": "File manager for the web with console and editor",
|
"description": "File manager for the web with console and editor",
|
||||||
"homepage": "http://cloudcmd.io",
|
"homepage": "http://cloudcmd.io",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue