diff --git a/client/client.js b/client/client.js index eddcfa6a..8823df4f 100644 --- a/client/client.js +++ b/client/client.js @@ -430,7 +430,7 @@ function CloudCmdProto(DOM) { } = Info; if (error) - return Dialog.alert(TITLE, error.responseText); + return Dialog.alert(error.responseText); const {childNodes} = panel; let i = childNodes.length; diff --git a/client/dom/buffer.js b/client/dom/buffer.js index 989c8788..a844384f 100644 --- a/client/dom/buffer.js +++ b/client/dom/buffer.js @@ -15,8 +15,6 @@ function BufferProto() { const CLASS = 'cut-file'; const COPY = 'copy'; const CUT = 'cut'; - const TITLE = 'Buffer'; - const Buffer = { cut : callIfEnabled.bind(null, cut), copy : callIfEnabled.bind(null, copy), @@ -25,7 +23,7 @@ function BufferProto() { }; function showMessage(msg) { - DOM.Dialog.alert(TITLE, msg); + DOM.Dialog.alert(msg); } function getNames() { diff --git a/client/dom/dialog.js b/client/dom/dialog.js index c2c9bfcd..157e6923 100644 --- a/client/dom/dialog.js +++ b/client/dom/dialog.js @@ -5,15 +5,17 @@ const { alert, prompt, confirm, + progress, }= require('smalltalk'); -module.exports = { - alert, - prompt, - confirm, -}; +const title = 'Cloud Commander'; -module.exports.alert.noFiles = (title) => { +module.exports.alert = (...a) => alert(title, ...a); +module.exports.prompt = (...a) => prompt(title, ...a); +module.exports.confirm = (...a) => confirm(title, ...a); +module.exports.progress = (...a) => progress(title, ...a); + +module.exports.alert.noFiles = () => { return alert(title, 'No files selected!', { cancel: false, }); diff --git a/client/dom/index.js b/client/dom/index.js index 900b1313..e7623e09 100644 --- a/client/dom/index.js +++ b/client/dom/index.js @@ -44,7 +44,6 @@ function CmdProto() { const Cmd = this; const SELECTED_FILE = 'selected-file'; - const TITLE = 'Cloud Commander'; const TabPanel = { 'js-left' : null, 'js-right' : null, @@ -97,7 +96,7 @@ function CmdProto() { const name = getName(); const cancel = false; - Dialog.prompt(TITLE, msg, name, {cancel}).then((name) => { + Dialog.prompt(msg, name, {cancel}).then((name) => { if (!name) return; @@ -342,7 +341,7 @@ function CmdProto() { }; if (Info.name === '..') { - Dialog.alert.noFiles(TITLE); + Dialog.alert.noFiles(); return callback(Error('No files selected!')); } @@ -756,11 +755,11 @@ function CmdProto() { const from = DOM.getCurrentName(current); if (from === '..') - return Dialog.alert.noFiles(TITLE); + return Dialog.alert.noFiles(); const cancel = false; - Dialog.prompt(TITLE, 'Rename', from, {cancel}).then((to) => { + Dialog.prompt('Rename', from, {cancel}).then((to) => { const isExist = !!DOM.getCurrentByName(to); const dirPath = DOM.getCurrentDirPath(); @@ -872,7 +871,7 @@ function CmdProto() { path, }); - Dialog.prompt(TITLE, msg, path, {cancel}) + Dialog.prompt(msg, path, {cancel}) .then(setPath) .then(CloudCmd.loadDir); }, diff --git a/client/dom/rest.js b/client/dom/rest.js index 7281c2cd..f6acd1b9 100644 --- a/client/dom/rest.js +++ b/client/dom/rest.js @@ -206,7 +206,7 @@ function RESTful() { Images.show.error(encoded); setTimeout(() => { - DOM.Dialog.alert(CloudCmd.TITLE, encoded); + DOM.Dialog.alert(encoded); }, 100); p.callback(Error(text)); diff --git a/client/dom/select-by-pattern.js b/client/dom/select-by-pattern.js index 74871fab..32f7ab7d 100644 --- a/client/dom/select-by-pattern.js +++ b/client/dom/select-by-pattern.js @@ -3,7 +3,6 @@ /* global DOM */ let SelectType = '*.*'; -const TITLE = 'Cloud Commander'; const {getRegExp} = require('../../common/util'); @@ -12,7 +11,7 @@ module.exports = (msg, files) => { const cancel = false; const {Dialog} = DOM; - Dialog.prompt(TITLE, allMsg, SelectType, {cancel}).then((type) => { + Dialog.prompt(allMsg, SelectType, {cancel}).then((type) => { SelectType = type; const regExp = getRegExp(type); diff --git a/client/dom/upload-files.js b/client/dom/upload-files.js index 9faddeaf..0b313311 100644 --- a/client/dom/upload-files.js +++ b/client/dom/upload-files.js @@ -12,8 +12,6 @@ const {alert} = require('./dialog'); const {FS} = require('../../common/cloudfunc'); -const {TITLE} = CloudCmd; - const onEnd = wraptile(_onEnd); const loadFile = wraptile(_loadFile); @@ -71,6 +69,6 @@ function _loadFile(dir, n, file, callback) { } function showError({message}) { - alert(TITLE, message); + alert(message); } diff --git a/client/key/vim/index.js b/client/key/vim/index.js index d8ad6629..7e66d37b 100644 --- a/client/key/vim/index.js +++ b/client/key/vim/index.js @@ -15,8 +15,6 @@ const { findPrevious, } = require('./find'); -const TITLE = 'Cloud Commander'; - const stopVisual = () => { visual(false); }; @@ -117,7 +115,7 @@ module.exports = (key, event) => { if (key === '/') { event.preventDefault(); - Dialog.prompt(TITLE, 'Find', '', {cancel: false}) + Dialog.prompt('Find', '', {cancel: false}) .then(find); return end(); diff --git a/client/modules/config.js b/client/modules/config.js index 4579b198..b22905dd 100644 --- a/client/modules/config.js +++ b/client/modules/config.js @@ -22,7 +22,6 @@ const {Dialog, setTitle} = DOM; const Name = 'Config'; CloudCmd[Name] = module.exports; -const alert = currify(Dialog.alert, Name); const loadSocket = promisify(DOM.loadSocket); @@ -116,12 +115,12 @@ function initSocket() { Config.save = saveHttp; }); - socket.on('err', alert); + socket.on('err', Dialog.alert); } function authCheck(socket) { socket.emit('auth', config('username'), config('password')); - socket.on('reject', wraptile(alert, 'Wrong credentials!')); + socket.on('reject', wraptile(Dialog.alert, 'Wrong credentials!')); } Config.save = saveHttp; @@ -138,7 +137,7 @@ function show() { function fillTemplate() { Files.get('config', (error, config) => { if (error) - return alert('Could not load config!'); + return Dialog.alert('Could not load config!'); const { editor, diff --git a/client/modules/edit-file.js b/client/modules/edit-file.js index 05207fa8..a91f901c 100644 --- a/client/modules/edit-file.js +++ b/client/modules/edit-file.js @@ -19,10 +19,8 @@ const { const {config} = CloudCmd; let Menu; - -const TITLE = 'Edit'; - let MSG_CHANGED; + const isLoading = fullstore(); const ConfigView = { @@ -111,7 +109,7 @@ function setListeners(editor) { function authCheck(spawn) { spawn.emit('auth', config('username'), config('password')); spawn.on('reject', () => { - Dialog.alert(TITLE, 'Wrong credentials!'); + Dialog.alert('Wrong credentials!'); }); } @@ -190,7 +188,7 @@ function isChanged() { return; const cancel = false; - Dialog.confirm(TITLE, MSG_CHANGED, {cancel}) + Dialog.confirm(MSG_CHANGED, {cancel}) .then(() => { editor.save(); }); diff --git a/client/modules/edit-names.js b/client/modules/edit-names.js index 9f5d4ee3..117cb49d 100644 --- a/client/modules/edit-names.js +++ b/client/modules/edit-names.js @@ -7,7 +7,6 @@ CloudCmd.EditNames = exports; const currify = require('currify/legacy'); const exec = require('execon'); const supermenu = require('supermenu'); -const smalltalk = require('smalltalk'); const multiRename = require('multi-rename'); const reject = Promise.reject.bind(Promise); @@ -15,8 +14,6 @@ const reject = Promise.reject.bind(Promise); const Info = DOM.CurrentInfo; const {Dialog} = DOM; -const TITLE = 'Edit Names'; -const alert = currify(Dialog.alert, TITLE); const refresh = currify(_refresh); const rename = currify(_rename); @@ -46,7 +43,7 @@ module.exports.show = (options) => { }; if (Info.name === '..' && names.length === 1) - return Dialog.alert.noFiles(TITLE); + return Dialog.alert.noFiles(); DOM.Events.addKey(keyListener); @@ -72,8 +69,8 @@ function keyListener(event) { EditNames.hide(); else if (ctrlMeta && event.keyCode === Key.P) - smalltalk - .prompt(TITLE, 'Apply pattern:', '[n][e]', {cancel: false}) + Dialog + .prompt('Apply pattern:', '[n][e]', {cancel: false}) .then(applyPattern); event.preventDefault(); @@ -217,7 +214,7 @@ function isChanged() { if (!editor.isChanged()) return; - Dialog.confirm(TITLE, msg, {cancel: false}) + Dialog.confirm(msg, {cancel: false}) .then(applyNames); } diff --git a/client/modules/konsole.js b/client/modules/konsole.js index 2eed9988..0683ef09 100644 --- a/client/modules/konsole.js +++ b/client/modules/konsole.js @@ -28,7 +28,6 @@ const {config} = CloudCmd; const cd = currify((fn, dir) => fn(`cd ${rmLastSlash(dir)}`)); const Name = 'Konsole'; -const TITLE = 'Console'; let Element; let Loaded; @@ -119,7 +118,7 @@ function authCheck(konsole) { konsole.emit('auth', config('username'), config('password')); konsole.on('reject', () => { - Dialog.alert(TITLE, 'Wrong credentials!'); + Dialog.alert('Wrong credentials!'); }); } @@ -149,7 +148,7 @@ const load = async () => { Util.timeEnd(Name + ' load'); if (error) - return Dialog.alert(TITLE, error.message, { + return Dialog.alert(error.message, { cancel: false, }); }; diff --git a/client/modules/markdown.js b/client/modules/markdown.js index c83c95c9..a25539df 100644 --- a/client/modules/markdown.js +++ b/client/modules/markdown.js @@ -7,8 +7,6 @@ const tryToCatch = require('try-to-catch/legacy'); CloudCmd.Markdown = exports; -const TITLE = 'Cloud Commander'; - const createElement = require('@cloudcmd/create-element'); const Images = require('../dom/images'); @@ -44,12 +42,11 @@ async function show(name, options = {}) { Images.hide(); if (error) - return alert(TITLE, error.message, { + return alert(error.message, { cancel: false, }); const className = 'help'; - const div = createElement('div', { className, innerHTML, diff --git a/client/modules/menu.js b/client/modules/menu.js index 8731f51d..ef1c6b67 100644 --- a/client/modules/menu.js +++ b/client/modules/menu.js @@ -24,8 +24,7 @@ const { } = DOM; const Info = DOM.CurrentInfo; -const TITLE = 'Cloud Commander'; -const alertNoFiles = wrap(Dialog.alert.noFiles)(TITLE); +const alertNoFiles = Dialog.alert.noFiles; const uploadTo = wrap(_uploadTo); let MenuShowedName; diff --git a/client/modules/operation/index.js b/client/modules/operation/index.js index 0f02c7e5..451ccd25 100644 --- a/client/modules/operation/index.js +++ b/client/modules/operation/index.js @@ -23,10 +23,7 @@ const removeQuery = (a) => a.replace(/\?.*/, ''); const Name = 'Operation'; CloudCmd[Name] = exports; -const { - TITLE, - config, -} = CloudCmd; +const {config} = CloudCmd; const {Dialog, Images} = DOM; const initOperations = wraptile(_initOperations); const authCheck = wraptile(_authCheck); @@ -55,7 +52,7 @@ const noFilesCheck = () => { const is = Boolean(!length); if (is) - return Dialog.alert.noFiles(TITLE); + return Dialog.alert.noFiles(); return is; }; @@ -88,7 +85,7 @@ function _authCheck(spawn, ok) { const alertDialog = wraptile(Dialog.alert); spawn.on('accept', accept(spawn)); - spawn.on('reject', alertDialog (TITLE, 'Wrong credentials!')); + spawn.on('reject', alertDialog ('Wrong credentials!')); spawn.emit('auth', config('username'), config('password')); } @@ -298,7 +295,7 @@ function promptDelete() { const cancel = false; - Dialog.confirm(TITLE, msg, {cancel}).then(() => { + Dialog.confirm(msg, {cancel}).then(() => { deleteSilent(files); }); } @@ -400,7 +397,7 @@ function _processFiles(options, data) { const str = `"${ name }" already exist. Overwrite?`; const cancel = false; - Dialog.confirm(TITLE, str, {cancel}).then(go); + Dialog.confirm(str, {cancel}).then(go); function go() { showLoad(); @@ -457,7 +454,7 @@ function twopack(operation, type) { checkEmpty('operation', operation); if (!names.length) - return Dialog.alert.noFiles(TITLE); + return Dialog.alert.noFiles(); switch(operation) { case 'extract': @@ -512,7 +509,7 @@ function message(msg, to, names) { const cancel = false; - return Dialog.prompt(TITLE, msg, to, {cancel}); + return Dialog.prompt(msg, to, {cancel}); } function load(callback) { @@ -521,7 +518,7 @@ function load(callback) { loadJS(file, (error) => { if (error) { - Dialog.alert(TITLE, error.message); + Dialog.alert(error.message); return exec(callback); } diff --git a/client/modules/operation/set-listeners.js b/client/modules/operation/set-listeners.js index d5538c2a..fa5f7cf1 100644 --- a/client/modules/operation/set-listeners.js +++ b/client/modules/operation/set-listeners.js @@ -3,8 +3,6 @@ /* global DOM */ /* global CloudCmd */ -const smalltalk = require('smalltalk'); - const { Dialog, Images, @@ -12,7 +10,6 @@ const { const forEachKey = require('for-each-key/legacy'); const wraptile = require('wraptile/legacy'); -const {TITLE} = CloudCmd; const format = require('./format'); @@ -34,7 +31,7 @@ module.exports = (options) => (emitter) => { const msg = `${operation} aborted`; lastError = true; - Dialog.alert(TITLE, msg, { + Dialog.alert(msg, { noCancel: true, }); }); @@ -43,8 +40,7 @@ module.exports = (options) => (emitter) => { const on = emitter.on.bind(emitter); const message = format(operation, from, to); - - const progress = smalltalk.progress(TITLE, message); + const progress = Dialog.progress(message); progress.catch(onAbort({ emitter, @@ -70,11 +66,11 @@ module.exports = (options) => (emitter) => { if (noContinue) { listeners.end(error); - Dialog.alert(TITLE, error); + Dialog.alert(error); return; } - Dialog.confirm(TITLE, error + '\n Continue?') + Dialog.confirm(error + '\n Continue?') .then(() => { emitter.continue(); }, () => { diff --git a/client/modules/terminal.js b/client/modules/terminal.js index 81a5ca89..ddb7cd37 100644 --- a/client/modules/terminal.js +++ b/client/modules/terminal.js @@ -14,8 +14,6 @@ const Images = require('../dom/images'); const loadParallel = promisify(load.parallel); -const TITLE = 'Terminal'; - const {Dialog} = DOM; const { Key, @@ -38,7 +36,7 @@ const loadAll = async () => { if (e) { const src = e.target.src.replace(window.location.href, ''); - return Dialog.alert(TITLE, `file ${src} could not be loaded`); + return Dialog.alert(`file ${src} could not be loaded`); } Loaded = true; @@ -103,7 +101,7 @@ function authCheck(spawn) { spawn.emit('auth', config('username'), config('password')); spawn.on('reject', () => { - Dialog.alert(TITLE, 'Wrong credentials!'); + Dialog.alert('Wrong credentials!'); }); }