diff --git a/client/client.js b/client/client.js index 4d5966e2..cb694321 100644 --- a/client/client.js +++ b/client/client.js @@ -58,9 +58,9 @@ function CloudCmdProto(DOM) { const Files = DOM.Files; this.log = log; - this.PREFIX = ''; + this.prefix = ''; this.prefixSocket = ''; - this.PREFIX_URL = ''; + this.prefixURL = ''; this.DIRCLIENT = '/dist/'; this.DIRCLIENT_MODULES = this.DIRCLIENT + 'modules/'; @@ -142,8 +142,8 @@ function CloudCmdProto(DOM) { load.js(src, callback); }; - CloudCmd.PREFIX = prefix; - CloudCmd.PREFIX_URL = prefix + apiURL; + CloudCmd.prefix = prefix; + CloudCmd.prefixURL = prefix + apiURL; CloudCmd.prefixSocket = config.prefixSocket; CloudCmd.config = (key) => config[key]; @@ -167,14 +167,14 @@ function CloudCmdProto(DOM) { }; function loadStyle(callback) { - const prefix = CloudCmd.PREFIX; + const {prefix} = CloudCmd; const name = prefix + '/dist/cloudcmd.common.css'; load.css(name, callback); } function loadPlugins(callback) { - const prefix = CloudCmd.PREFIX; + const {prefix} = CloudCmd; const plugins = prefix + '/plugins.js'; load.js(plugins, callback); @@ -203,7 +203,7 @@ function CloudCmdProto(DOM) { }; this.logOut = () => { - const url = CloudCmd.PREFIX + '/logout'; + const url = CloudCmd.prefix + '/logout'; const error = () => document.location.reload(); DOM.Storage.clear(); @@ -414,6 +414,7 @@ function CloudCmdProto(DOM) { Files.get(names, (error, templFile, templPath, templLink, templPathLink) => { const Dialog = DOM.Dialog; const panel = panelParam || DOM.getPanel(); + const {prefix} = CloudCmd; const { dir, @@ -434,7 +435,7 @@ function CloudCmdProto(DOM) { order : options.order, data : json, id : panel.id, - prefix : CloudCmd.PREFIX, + prefix, template : { file : templFile, path : templPath, diff --git a/client/dom/current-file.js b/client/dom/current-file.js index 56084eda..f8599420 100644 --- a/client/dom/current-file.js +++ b/client/dom/current-file.js @@ -33,8 +33,8 @@ module.exports._CURRENT_FILE = CURRENT_FILE; module.exports.setCurrentName = (name, current) => { const Info = DOM.CurrentInfo; const {link} = Info; - const {PREFIX} = CloudCmd; - const dir = PREFIX + FS + Info.dirPath; + const {prefix} = CloudCmd; + const dir = prefix + FS + Info.dirPath; const encoded = encode(name); link.title = encoded; @@ -84,7 +84,7 @@ module.exports.getCurrentDirPath = (panel = DOM.getPanel()) => { module.exports.getCurrentPath = (currentFile) => { const current = currentFile || DOM.getCurrentFile(); const element = DOM.getByTag('a', current)[0]; - const prefix = CloudCmd.PREFIX; + const {prefix} = CloudCmd; const path = element .getAttribute('href') diff --git a/client/dom/current-file.spec.js b/client/dom/current-file.spec.js index 6efcf00b..c274117c 100644 --- a/client/dom/current-file.spec.js +++ b/client/dom/current-file.spec.js @@ -182,7 +182,7 @@ test('current-file: isCurrentFile', (t) => { function getCloudCmd({emit} = {}) { return { - PREFIX: '', + prefix: '', emit: emit || sinon.stub(), }; } diff --git a/client/dom/directory.js b/client/dom/directory.js index 7a58025b..5740b91b 100644 --- a/client/dom/directory.js +++ b/client/dom/directory.js @@ -27,7 +27,7 @@ module.exports = (items) => { .replace(/\/$/, ''); const uploader = philip(entries, (type, name, data, i, n, callback) => { - const prefixURL = CloudCmd.PREFIX_URL; + const {prefixURL} = CloudCmd; const full = prefixURL + FS + path + name; let upload; diff --git a/client/dom/files.js b/client/dom/files.js index 562738f0..254b0b5a 100644 --- a/client/dom/files.js +++ b/client/dom/files.js @@ -98,7 +98,7 @@ function showError(name) { } function getSystemFile(file, callback) { - const prefix = CloudCmd.PREFIX; + const {prefix} = CloudCmd; if (!Promises[file]) Promises[file] = new Promise((success, error) => { diff --git a/client/dom/index.js b/client/dom/index.js index 255250c5..cbf8d6a0 100644 --- a/client/dom/index.js +++ b/client/dom/index.js @@ -468,8 +468,9 @@ function CmdProto() { */ this.setHistory = (data, title, url) => { const ret = window.history; + const {prefix} = CloudCmd; - url = CloudCmd.PREFIX + url; + url = prefix + url; if (ret) history.pushState(data, title, url); diff --git a/client/dom/load-remote.js b/client/dom/load-remote.js index 2b1578bc..775d2148 100644 --- a/client/dom/load-remote.js +++ b/client/dom/load-remote.js @@ -14,7 +14,7 @@ const Files = require('./files'); const parallel = wraptile(load.parallel); module.exports = (name, options, callback = options) => { - const {PREFIX, config} = CloudCmd; + const {prefix, config} = CloudCmd; const o = options; if (o.name && window[o.name]) @@ -37,7 +37,7 @@ module.exports = (name, options, callback = options) => { } const localURL = local.map((url) => { - return PREFIX + url; + return prefix + url; }); const remoteURL = remoteTmpls.map((tmpl) => { diff --git a/client/dom/rest.js b/client/dom/rest.js index 6e0faa01..120fe563 100644 --- a/client/dom/rest.js +++ b/client/dom/rest.js @@ -176,9 +176,9 @@ function RESTful() { function sendRequest(params) { const p = params; - const prefixUrl = CloudCmd.PREFIX_URL; + const {prefixURL} = CloudCmd; - p.url = prefixUrl + p.url; + p.url = prefixURL + p.url; p.url = encodeURI(p.url); /* diff --git a/client/dom/upload-files.js b/client/dom/upload-files.js index accbb203..288ab24b 100644 --- a/client/dom/upload-files.js +++ b/client/dom/upload-files.js @@ -49,8 +49,8 @@ function _loadFile(dir, n, file, callback) { const name = file.name; const path = dir + name; - const {PREFIX_URL} = CloudCmd; - const api = PREFIX_URL + FS; + const {prefixURL} = CloudCmd; + const api = prefixURL + FS; const percent = (i, n, per = 100) => { return Math.round(i * per / n); diff --git a/client/listeners/index.js b/client/listeners/index.js index 85bb0e2d..0e40d24e 100644 --- a/client/listeners/index.js +++ b/client/listeners/index.js @@ -180,7 +180,7 @@ function isNoCurrent(panel) { function decodePath(path){ const url = CloudCmd.HOST; - const prefix = CloudCmd.PREFIX; + const {prefix} = CloudCmd; const prefixReg = RegExp('^' + prefix + FS); return decodeURI(path) diff --git a/client/load-module.js b/client/load-module.js index 130d1de6..b1e91790 100644 --- a/client/load-module.js +++ b/client/load-module.js @@ -28,7 +28,7 @@ module.exports = function loadModule(params) { CloudCmd[name] = () => { exec(doBefore); - const prefix = CloudCmd.PREFIX; + const {prefix} = CloudCmd; const pathFull = prefix + CloudCmd.DIRCLIENT_MODULES + path + '.js'; return loadJS(pathFull).then(async () => { diff --git a/client/modules/config.js b/client/modules/config.js index c03f51d0..de7b6cef 100644 --- a/client/modules/config.js +++ b/client/modules/config.js @@ -75,7 +75,7 @@ function initSocket() { const href = getHost(); const { prefixSocket, - PREFIX, + prefix, } = CloudCmd; const ONE_MINUTE = 60 * 1000; @@ -83,7 +83,7 @@ function initSocket() { const socket = io.connect(href + prefixSocket + '/config', { reconnectionAttempts: Infinity, reconnectionDelay: ONE_MINUTE, - path: PREFIX + '/socket.io' + path: prefix + '/socket.io' }); const save = (data) => { @@ -120,7 +120,7 @@ function show() { if (!CloudCmd.config('configDialog')) return; - const prefix = CloudCmd.PREFIX; + const {prefix} = CloudCmd; const funcs = [ exec.with(Files.get, 'config-tmpl'), exec.with(load.css, prefix + '/dist/config.css'), diff --git a/client/modules/edit-names.js b/client/modules/edit-names.js index bd4bce69..e6e069bc 100644 --- a/client/modules/edit-names.js +++ b/client/modules/edit-names.js @@ -124,8 +124,9 @@ function getDir(root, dir) { function _rename(path, from, to, root) { const dir = getDir(root, path); + const {prefix} = CloudCmd; - return fetch(CloudCmd.PREFIX + '/rename', { + return fetch(`${prefix}/rename`, { method: 'put', credentials: 'include', body: JSON.stringify({ diff --git a/client/modules/edit.js b/client/modules/edit.js index 2fda3cd2..d6969ddb 100644 --- a/client/modules/edit.js +++ b/client/modules/edit.js @@ -103,10 +103,10 @@ module.exports.hide = () => { }; const loadFiles = async (element) => { - const socketPath = CloudCmd.PREFIX; + const {prefix} = CloudCmd; + const socketPath = prefix; const {prefixSocket} = CloudCmd; - const prefix = socketPath + '/' + EditorName; - const url = prefix + '/' + EditorName + '.js'; + const url = `${prefix}/${EditorName}/${EditorName}.js`; time(Name + ' load'); diff --git a/client/modules/konsole.js b/client/modules/konsole.js index 82f4c56c..9ab097a9 100644 --- a/client/modules/konsole.js +++ b/client/modules/konsole.js @@ -53,7 +53,7 @@ module.exports.clear = () => { }; function getPrefix() { - return CloudCmd.PREFIX + '/console'; + return CloudCmd.prefix + '/console'; } function getPrefixSocket() { @@ -91,7 +91,7 @@ const create = async () => { env: getEnv(), prefix: getPrefix(), prefixSocket: getPrefixSocket(), - socketPath: CloudCmd.PREFIX, + socketPath: CloudCmd.prefix, }; Element = createElement('div', { diff --git a/client/modules/menu.js b/client/modules/menu.js index c1b88a47..a4a42d80 100644 --- a/client/modules/menu.js +++ b/client/modules/menu.js @@ -252,7 +252,7 @@ function preDownload() { function download(type) { const TIME = 30 * 1000; - const prefixUr = CloudCmd.PREFIX_URL; + const {prefixURL} = CloudCmd; const PACK = '/pack'; const date = Date.now(); const files = DOM.getActiveFiles(); @@ -277,9 +277,9 @@ function download(type) { let src; if (isDir) - src = prefixUr + PACK + encodedPath + DOM.getPackerExt(type); + src = prefixURL + PACK + encodedPath + DOM.getPackerExt(type); else - src = prefixUr + FS + encodedPath + '?download'; + src = prefixURL + FS + encodedPath + '?download'; const element = createElement('iframe', { id : id + '-' + date, diff --git a/client/modules/operation/index.js b/client/modules/operation/index.js index f52c395e..e6be55a1 100644 --- a/client/modules/operation/index.js +++ b/client/modules/operation/index.js @@ -71,7 +71,7 @@ module.exports.init = promisify((callback) => { if (!config('progress')) return callback(); - load(initOperations(CloudCmd.PREFIX, callback)); + load(initOperations(CloudCmd.prefix, callback)); }, (callback) => { Loaded = true; @@ -457,7 +457,7 @@ function message(msg, to, names) { } function load(callback) { - const prefix = CloudCmd.PREFIX; + const {prefix} = CloudCmd; const file = `${prefix}/fileop/fileop.js`; loadJS(file, (error) => { diff --git a/client/modules/terminal.js b/client/modules/terminal.js index 77f8e40d..624ca8f0 100644 --- a/client/modules/terminal.js +++ b/client/modules/terminal.js @@ -28,12 +28,12 @@ const {config} = CloudCmd; const loadAll = async () => { const { - PREFIX, + prefix, } = CloudCmd; - const prefix = getPrefix(); - const js = `${prefix}/gritty.js`; - const css = `${PREFIX}/dist/terminal.css`; + const prefixGritty = getPrefix(); + const js = `${prefixGritty}/gritty.js`; + const css = `${prefix}/dist/terminal.css`; const [e] = await tryToCatch(loadParallel, [js, css]); @@ -64,7 +64,7 @@ function hide () { } function getPrefix() { - return CloudCmd.PREFIX + '/gritty'; + return CloudCmd.prefix + '/gritty'; } function getPrefixSocket() { @@ -84,7 +84,7 @@ function create() { const options = { env: getEnv(), prefix: getPrefixSocket(), - socketPath: CloudCmd.PREFIX, + socketPath: CloudCmd.prefix, fontFamily: 'Droid Sans Mono', }; diff --git a/client/modules/view.js b/client/modules/view.js index 6373a4c5..2e6e84ca 100644 --- a/client/modules/view.js +++ b/client/modules/view.js @@ -80,7 +80,7 @@ module.exports.init = async () => { }; function show(data, options) { - const prefixUrl = CloudCmd.PREFIX_URL + FS; + const prefixURL = CloudCmd.prefixURL + FS; if (Loading) return; @@ -103,7 +103,7 @@ function show(data, options) { Images.show.load(); - const path = prefixUrl + Info.path; + const path = prefixURL + Info.path; const type = getType(path); switch(type) { @@ -111,7 +111,7 @@ function show(data, options) { return viewFile(); case 'image': - return viewImage(path, prefixUrl); + return viewImage(path, prefixURL); case 'media': return viewMedia(path); @@ -185,10 +185,10 @@ function hide() { modal.close(); } -function viewImage(href, prefixUrl) { +function viewImage(href, prefixURL) { const makeTitle = (path) => { return { - href: prefixUrl + path, + href: prefixURL + path, title: encode(basename(path)), }; }; @@ -297,12 +297,12 @@ function check(src, callback) { * @callback - executes, when everything loaded */ async function loadAll() { - const {PREFIX} = CloudCmd; + const {prefix} = CloudCmd; time(Name + ' load'); Loading = true; - await loadCSS(PREFIX + '/dist/view.css'); + await loadCSS(`${prefix}/dist/view.css`); Loading = false; }