refactor(cloudcmd) PREFIX -> prefix

This commit is contained in:
coderaiser 2018-10-29 18:44:10 +02:00
parent 6e65ad615b
commit 5e9db8eb3c
19 changed files with 53 additions and 50 deletions

View file

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

View file

@ -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({

View file

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

View file

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

View file

@ -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,

View file

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

View file

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

View file

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