chore: client: lint

This commit is contained in:
coderiaser 2025-01-20 18:18:52 +02:00
parent 2fc503f71f
commit d8da7922d9
12 changed files with 71 additions and 101 deletions

View file

@ -261,12 +261,10 @@ test('current-file: isCurrentIsDir: file', (t) => {
t.end();
});
function getCloudCmd({emit} = {}) {
return {
prefix: '',
emit: emit || stub(),
};
}
const getCloudCmd = ({emit} = {}) => ({
prefix: '',
emit: emit || stub(),
});
test('current-file: parseNameAttribute', (t) => {
const result = currentFile._parseNameAttribute('js-file-aGVsbG8mbmJzcDt3b3JsZA==');

View file

@ -63,14 +63,8 @@ module.exports = (items) => {
uploader.on('end', CloudCmd.refresh);
};
function percent(i, n, per = 100) {
return Math.round(i * per / n);
}
const percent = (i, n, per = 100) => Math.round(i * per / n);
function uploadFile(url, data) {
return DOM.load.put(url, data);
}
const uploadFile = (url, data) => DOM.load.put(url, data);
function uploadDir(url) {
return DOM.load.put(`${url}?dir`);
}
const uploadDir = (url) => DOM.load.put(`${url}?dir`);

View file

@ -10,9 +10,7 @@ const LOADING = 'loading';
const HIDDEN = 'hidden';
const ERROR = 'error';
function getLoadingType() {
return isSVG() ? '-svg' : '-gif';
}
const getLoadingType = () => isSVG() ? '-svg' : '-gif';
module.exports.get = getElement;
/**

View file

@ -17,42 +17,40 @@ module.exports = (name, options, callback = options) => {
if (o.name && window[o.name])
return callback();
Files
.get('modules')
.then(async (modules) => {
const online = config('online') && navigator.onLine;
const module = findObjByNameInArr(modules.remote, name);
const isArray = itype.array(module.local);
const {version} = module;
let remoteTmpls;
let local;
if (isArray) {
remoteTmpls = module.remote;
local = module.local;
} else {
remoteTmpls = [module.remote];
local = [module.local];
}
const localURL = local.map((url) => prefix + url);
const remoteURL = remoteTmpls.map((tmpl) => {
return rendy(tmpl, {
version,
});
Files.get('modules').then(async (modules) => {
const online = config('online') && navigator.onLine;
const module = findObjByNameInArr(modules.remote, name);
const isArray = itype.array(module.local);
const {version} = module;
let remoteTmpls;
let local;
if (isArray) {
remoteTmpls = module.remote;
local = module.local;
} else {
remoteTmpls = [module.remote];
local = [module.local];
}
const localURL = local.map((url) => prefix + url);
const remoteURL = remoteTmpls.map((tmpl) => {
return rendy(tmpl, {
version,
});
if (online) {
const [e] = await tryToCatch(load.parallel, remoteURL);
if (!e)
return callback();
}
const [e] = await tryToCatch(load.parallel, localURL);
callback(e);
});
if (online) {
const [e] = await tryToCatch(load.parallel, remoteURL);
if (!e)
return callback();
}
const [e] = await tryToCatch(load.parallel, localURL);
callback(e);
});
};

View file

@ -11,6 +11,7 @@ const load = require('load.js');
const {MAX_FILE_SIZE: maxSize} = require('../../common/cloudfunc');
const {time, timeEnd} = require('../../common/util');
const getEditor = () => editor;
const isFn = (a) => typeof a === 'function';
const loadJS = load.js;
@ -91,10 +92,6 @@ module.exports.show = (options) => {
module.exports.getEditor = getEditor;
function getEditor() {
return editor;
}
module.exports.getElement = () => Element;
module.exports.hide = () => {

View file

@ -46,22 +46,18 @@ module.exports.clear = () => {
konsole.clear();
};
function getPrefix() {
return CloudCmd.prefix + '/console';
}
const getPrefix = () => CloudCmd.prefix + '/console';
function getPrefixSocket() {
return CloudCmd.prefixSocket + '/console';
}
function getEnv() {
return {
ACTIVE_DIR: DOM.getCurrentDirPath.bind(DOM),
PASSIVE_DIR: DOM.getNotCurrentDirPath.bind(DOM),
CURRENT_NAME: DOM.getCurrentName.bind(DOM),
CURRENT_PATH: () => Info.path,
};
}
const getEnv = () => ({
ACTIVE_DIR: DOM.getCurrentDirPath.bind(DOM),
PASSIVE_DIR: DOM.getNotCurrentDirPath.bind(DOM),
CURRENT_NAME: DOM.getCurrentName.bind(DOM),
CURRENT_PATH: () => Info.path,
});
async function onPath(path) {
if (Info.dirPath === path)

View file

@ -226,9 +226,7 @@ function beforeShow(callback, params) {
return isShow;
}
function beforeClick(name) {
return MenuShowedName !== name;
}
const beforeClick = (name) => MenuShowedName !== name;
async function _uploadTo(nameModule) {
const [error, data] = await Info.getData();

View file

@ -75,22 +75,18 @@ function hide() {
CloudCmd.View.hide();
}
function getPrefix() {
return CloudCmd.prefix + '/gritty';
}
const getPrefix = () => CloudCmd.prefix + '/gritty';
function getPrefixSocket() {
return CloudCmd.prefixSocket + '/gritty';
}
function getEnv() {
return {
ACTIVE_DIR: DOM.getCurrentDirPath,
PASSIVE_DIR: DOM.getNotCurrentDirPath,
CURRENT_NAME: DOM.getCurrentName,
CURRENT_PATH: DOM.getCurrentPath,
};
}
const getEnv = () => ({
ACTIVE_DIR: DOM.getCurrentDirPath,
PASSIVE_DIR: DOM.getNotCurrentDirPath,
CURRENT_NAME: DOM.getCurrentName,
CURRENT_PATH: DOM.getCurrentPath,
});
function create(createOptions) {
const {

View file

@ -57,22 +57,18 @@ function hide() {
CloudCmd.View.hide();
}
function getPrefix() {
return CloudCmd.prefix + '/gritty';
}
const getPrefix = () => CloudCmd.prefix + '/gritty';
function getPrefixSocket() {
return CloudCmd.prefixSocket + '/gritty';
}
function getEnv() {
return {
ACTIVE_DIR: DOM.getCurrentDirPath,
PASSIVE_DIR: DOM.getNotCurrentDirPath,
CURRENT_NAME: DOM.getCurrentName,
CURRENT_PATH: DOM.getCurrentPath,
};
}
const getEnv = () => ({
ACTIVE_DIR: DOM.getCurrentDirPath,
PASSIVE_DIR: DOM.getNotCurrentDirPath,
CURRENT_NAME: DOM.getCurrentName,
CURRENT_PATH: DOM.getCurrentPath,
});
function create() {
const options = {

View file

@ -45,9 +45,7 @@ function isMedia(name) {
return isAudio(name) || isVideo(name);
}
function isAudio(name) {
return /\.(mp3|ogg|m4a)$/i.test(name);
}
const isAudio = (name) => /\.(mp3|ogg|m4a)$/i.test(name);
function isVideo(name) {
return /\.(mp4|avi|webm)$/i.test(name);

View file

@ -55,7 +55,10 @@ CloudCmd[Name] = module.exports;
const Info = DOM.CurrentInfo;
const {Key} = CloudCmd;
const basename = (a) => a.split('/').pop();
const basename = (a) => a
.split('/')
.pop();
let El;
let TemplateAudio;

View file

@ -2,6 +2,7 @@
const {extname} = require('node:path');
const currify = require('currify');
const isAudio = (name) => /\.(mp3|ogg|m4a)$/i.test(name);
const testRegExp = currify((name, reg) => reg.test(name));
const getRegExp = (ext) => RegExp(`\\.${ext}$`, 'i');
@ -53,9 +54,6 @@ function isMedia(name) {
}
module.exports.isAudio = isAudio;
function isAudio(name) {
return /\.(mp3|ogg|m4a)$/i.test(name);
}
function isVideo(name) {
return /\.(mp4|avi|webm)$/i.test(name);