lint compliance

This commit is contained in:
yflory 2024-03-07 14:58:14 +01:00
parent dd0c5598ea
commit 1c2dc2cbef
33 changed files with 51 additions and 106 deletions

View file

@ -14,8 +14,9 @@ www/scratch
www/accounts
www/lib
www/accounts
www/worker
www/todo
www/common/toolbar.js
www/common/hyperscript.js
www/pad/wysiwygarea-plugin.js

View file

@ -64,7 +64,6 @@ define([
return bar;
};
var hasErrored = false;
var isOffline = false;
var updateLoadingProgress = function (data) {
if (!built || !data) { return; }
@ -102,7 +101,6 @@ define([
var el3 = document.querySelector('.cp-loading-progress-container');
if (el3) { el3.innerHTML = makeBar(data); }
} catch (e) {
//if (!hasErrored) { console.error(e); }
}
};
window.CryptPad_updateLoadingProgress = updateLoadingProgress;
@ -115,7 +113,6 @@ define([
return;
}
hasErrored = true;
var err2;
if (err === 'Script error.') {
err2 = Messages.error_unhelpfulScriptError;

View file

@ -265,13 +265,6 @@ Pinning.resetUserPins = function (Env, safeKey, channelList, _cb) {
pins[channel] = true;
});
var oldChannels;
if (session.channels && typeof(session.channels) === 'object') {
oldChannels = Object.keys(session.channels);
} else {
oldChannels = [];
}
// update in-memory cache IFF the reset was allowed.
session.channels = pins;
cb();

View file

@ -45,7 +45,6 @@ var PROGRESS_FACTOR = 1000;
var evictArchived = function (Env, cb) {
var Log;
var store;
var pinStore;
var blobs;
var retentionTime = +new Date() - (Env.archiveRetentionTime * 24 * 3600 * 1000);
@ -74,7 +73,6 @@ var evictArchived = function (Env, cb) {
var loadStorage = function () {
store = Env.store;
pinStore = Env.pinStore;
Log = Env.Log;
blobs = Env.blobStore;
};

View file

@ -146,9 +146,8 @@ var rpc = function (Env, Server, userId, data, respond) {
var publicKey = msg.shift();
// make sure a user object is initialized in the cookie jar
var session;
if (publicKey) {
session = Core.getSession(Env.Sessions, publicKey);
Core.getSession(Env.Sessions, publicKey);
} else {
Env.Log.debug("NO_PUBLIC_KEY_PROVIDED", publicKey);
}

View file

@ -225,7 +225,8 @@ var run = Tasks.run = function (env, path, cb) {
var CURRENT = +new Date();
var Log = env.log;
var task, time, command, args;
var task, time, command;
//var args;
nThen(function (w) {
read(env, path, w(function (err, _task) {
@ -243,7 +244,7 @@ var run = Tasks.run = function (env, path, cb) {
}
command = task[1];
args = task.slice(2);
//args = task.slice(2);
}));
}).nThen(function (w) {
switch (command) {

View file

@ -149,11 +149,10 @@ var createUser = function (config, cb) {
//wc.leave();
}));
}).nThen(function () {
user.cleanup = function (cb) {
user.cleanup = function (/* cb */) {
//console.log("Destroying user");
// TODO remove your mailbox
user.destroy.fire();
cb = cb;
};
cb(void 0, user);

View file

@ -249,11 +249,10 @@ var createUser = function (config, cb) {
}));
}).nThen(function () {
user.cleanup = function (cb) {
user.cleanup = function (/* cb */) {
//console.log("Destroying user");
// TODO remove your mailbox
user.destroy.fire();
cb = cb;
};
cb(void 0, user);
@ -897,13 +896,14 @@ nThen(function (w) {
text: "CAMEMBERT",
}
}), bob.curveKeys.curvePublic);
alice.anonRpc.send('WRITE_PRIVATE_MESSAGE', [bob.mailboxChannel, message], w(function (err, response) {
alice.anonRpc.send('WRITE_PRIVATE_MESSAGE', [bob.mailboxChannel, message], w(function (err/*, response*/) {
if (err) {
return void console.error(err);
}
// TODO validate that the write was actually successful by checking its size
response = response;
//response = response;
// shutdown doesn't work, so we need to do this instead
}));
}).nThen(function () {

View file

@ -157,8 +157,7 @@ nThen(function (w) {
});
};
var broadcast = (command, data, cb) => {
cb = cb; // TODO nThen/concurrency
var broadcast = (command, data/*, cb*/) => {
for (const worker of Object.values(Cluster.workers)) {
sendCommand(worker, command, data /*, cb */);
}

View file

@ -61,7 +61,6 @@ define([
existing = Object.keys(res.tags).sort();
}));
}).nThen(function (waitFor) {
var _err;
hrefs.forEach(function (href) {
common.getPadAttribute('tags', waitFor(function (err, res) {
if (err) {
@ -69,7 +68,6 @@ define([
UI.alert(Messages.tags_noentry);
}
waitFor.abort();
_err = err;
return void console.error(err);
}
allTags[href] = res || [];
@ -362,7 +360,7 @@ define([
buttons: contactsButtons,
});
var linkName, linkPassword, linkMessage, linkError, linkSpinText;
var linkName, linkPassword, linkMessage, linkError;
var linkForm, linkSpin, linkResult, linkUses, linkRole;
var linkWarning;
// Invite from link
@ -429,7 +427,7 @@ define([
style: 'display: none;'
}, [
h('i.fa.fa-spinner.fa-spin'),
linkSpinText = h('span', Messages.team_inviteLinkLoading)
h('span', Messages.team_inviteLinkLoading)
]),
linkResult = h('div', {
style: 'display: none;'

View file

@ -1566,7 +1566,6 @@ define([
var oldChannel;
var warning;
var FileCrypto;
var MediaTag;
var Upload;
Nthen(function (waitFor) {
@ -1577,12 +1576,10 @@ define([
}
}).nThen(function (waitFor) {
require([
'/file/file-crypto.js',
'/common/media-tag.js',
'/common/outer/upload.js',
'/components/tweetnacl/nacl-fast.min.js'
], waitFor(function (_FileCrypto, _MT, _Upload) {
FileCrypto = _FileCrypto;
], waitFor(function (_MT, _Upload) {
MediaTag = _MT;
Upload = _Upload;
}));
@ -1952,7 +1949,7 @@ define([
var oldBytes = data.oldBytes; // From Scrypt
var newBytes = data.newBytes; // From Scrypt
var secret = Hash.getSecrets('drive', hash);
var newHash, newHref, newSecret;
var newHash, newSecret;
var oldIsOwned = false;
var blockHash = LocalStore.getBlockHash();
@ -2031,7 +2028,6 @@ define([
// Get the current content, store it in the new user file
// and make sure the new user drive is owned
newHash = Hash.createRandomHash('drive');
newHref = '/drive/#' + newHash;
newSecret = Hash.getSecrets('drive', newHash);
var optsPut = {

View file

@ -757,7 +757,7 @@ define([
var priv = common.getMetadataMgr().getPrivateData();
var user = common.getMetadataMgr().getUserData();
var edPublic = priv.edPublic;
var strangers = 0;
//var strangers = 0;
var _owners = {};
list.forEach(function (ed) {
// If a friend is an owner, add their name to the list
@ -808,7 +808,7 @@ define([
// in the pad itself (as is the case of the uid in rich text comments)
// TODO or just implement "Acquaintances"
};
strangers++;
//strangers++;
});
if (!Object.keys(_owners).length) { return; }
/*

View file

@ -278,6 +278,7 @@ define([
if (code.length !== 6 || /\D/.test(code)) {
return void UI.warn(Messages.settings_otp_invalid);
}
if (lock) { return; }
confirmOTP.disabled = true;
lock = true;

View file

@ -104,8 +104,7 @@ define([
};
};
Block.proveAncestor = function (O /* oldBlockKeys */, N /* newBlockKeys */) {
N = N;
Block.proveAncestor = function (O /* oldBlockKeys, N, newBlockKeys */) {
var u8_pub = Util.find(O, ['sign', 'publicKey']);
var u8_secret = Util.find(O, ['sign', 'secretKey']);
try {

View file

@ -545,12 +545,10 @@ define([
// Make sure we are a member of this team
var myTeams = Util.find(ctx, ['store', 'proxy', 'teams']) || {};
var teamId;
var team;
Object.keys(myTeams).some(function (k) {
var _team = myTeams[k];
if (_team.channel === content.teamData.channel) {
teamId = k;
team = _team;
return true;
}
});

View file

@ -74,8 +74,7 @@ define([
});
};
var setName = function (ctx, value, cb) {
cb = cb || function () {};
var setName = function (ctx, value) {
ctx.listmap.proxy.name = value;
Realtime.whenRealtimeSyncs(ctx.listmap.realtime, function () {
if (!ctx.listmap) { return; }

View file

@ -582,7 +582,6 @@ var factory = function (Util, Hash, CPNetflux, Sortify, nThen, Crypto, Feedback)
delete ref.internal.checkpointTimeout;
};
var webChannel;
roster.stop = function () {
if (ref.internal.cpNetflux && typeof(ref.internal.cpNetflux.stop) === "function") {
ref.internal.cpNetflux.stop();
@ -604,9 +603,8 @@ var factory = function (Util, Hash, CPNetflux, Sortify, nThen, Crypto, Feedback)
}
config.onCacheReady(roster);
};
var onReady = function (info) {
var onReady = function () {
//console.log("READY");
webChannel = info;
ready = true;
cb(void 0, roster);
};

View file

@ -169,12 +169,12 @@ self.addEventListener('message', function (e) {
self.tabs[cId].msgEv.fire(e);
}
});
self.addEventListener('install', function (e) {
self.addEventListener('install', function () {
debug('V1 installing…');
self.skipWaiting();
});
self.addEventListener('activate', function (e) {
self.addEventListener('activate', function () {
debug('V1 now ready to handle fetches!');
});

View file

@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: AGPL-3.0-or-later
/* global importScripts, onconnect */
/* global importScripts */
importScripts('/components/requirejs/require.js');
@ -162,7 +162,7 @@ var init = function (client, cb) {
});
};
onconnect = function(e) {
addEventListener('connect', function(e) {
debug('New SharedWorker client');
var port = e.ports[0];
var cId = Number(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER));
@ -187,5 +187,5 @@ onconnect = function(e) {
client.msgEv.fire(e);
}
};
};
});

View file

@ -13,9 +13,6 @@ define([
var badStateTimeout = typeof(AppConfig.badStateTimeout) === 'number' ?
AppConfig.badStateTimeout : 30000;
var verbose = function (x) { console.log(x); };
verbose = function () {}; // comment out to enable verbose logging
module.exports.start = function (config) {
var onConnectionChange = config.onConnectionChange || function () { };
var onRemote = config.onRemote || function () { };

View file

@ -225,14 +225,12 @@ define([
var $textarea = exp.$textarea = textarea ? $(textarea) : $('#editor1');
if (!$textarea.length) { $textarea = exp.$textarea = $pad.contents().find('#editor1'); }
var Title;
var onLocal = function () {};
var $drawer;
exp.init = function (local, title, toolbar) {
if (typeof local === "function") {
onLocal = local;
}
Title = title;
$drawer = toolbar.$theme || $();
};

View file

@ -114,7 +114,6 @@ define([
var SecureIframe;
var UnsafeIframe;
var OOIframe;
var Messaging;
var Notifier;
var Utils = {
nThen: nThen
@ -142,7 +141,6 @@ define([
'/secureiframe/main.js',
'/unsafeiframe/main.js',
'/common/onlyoffice/ooiframe.js',
'/common/common-messaging.js',
'/common/common-notifier.js',
'/common/common-hash.js',
'/common/common-util.js',
@ -158,7 +156,7 @@ define([
'/common/userObject.js',
'optional!/api/instance'
], waitFor(function (_CpNfOuter, _Cryptpad, _Crypto, _Cryptget, _SFrameChannel,
_SecureIframe, _UnsafeIframe, _OOIframe, _Messaging, _Notifier, _Hash, _Util, _Realtime, _Notify,
_SecureIframe, _UnsafeIframe, _OOIframe, _Notifier, _Hash, _Util, _Realtime, _Notify,
_Constants, _Feedback, _LocalStore, _Block, _Cache, _AppConfig, /* _Test,*/ _UserObject,
_Instance) {
CpNfOuter = _CpNfOuter;
@ -169,7 +167,6 @@ define([
SecureIframe = _SecureIframe;
UnsafeIframe = _UnsafeIframe;
OOIframe = _OOIframe;
Messaging = _Messaging;
Notifier = _Notifier;
Utils.Hash = _Hash;
Utils.Util = _Util;

View file

@ -34,8 +34,6 @@ MessengerUI, Messages, Pages) {
var BOTTOM_LEFT_CLS = Bar.constants.bottomL = 'cp-toolbar-bottom-left';
var BOTTOM_MID_CLS = Bar.constants.bottomM = 'cp-toolbar-bottom-mid';
var BOTTOM_RIGHT_CLS = Bar.constants.bottomR = 'cp-toolbar-bottom-right';
var LEFTSIDE_CLS = Bar.constants.leftside = 'cp-toolbar-leftside';
var RIGHTSIDE_CLS = Bar.constants.rightside = 'cp-toolbar-rightside';
var FILE_CLS = Bar.constants.file = 'cp-toolbar-file';
var DRAWER_CLS = Bar.constants.drawer = 'cp-toolbar-drawer-content';
var HISTORY_CLS = Bar.constants.history = 'cp-toolbar-history';
@ -137,7 +135,7 @@ MessengerUI, Messages, Pages) {
$('<span>', {'class': USERADMIN_CLS + ' cp-dropdown-container'}).hide().appendTo($userContainer);
$toolbar.append($topContainer);
var $bottom = $(h('div.'+BOTTOM_CLS, [
$(h('div.'+BOTTOM_CLS, [
h('div.'+BOTTOM_LEFT_CLS),
h('div.'+BOTTOM_MID_CLS),
h('div.'+BOTTOM_RIGHT_CLS)
@ -506,7 +504,7 @@ MessengerUI, Messages, Pages) {
return $container;
};
createCollapse = function (toolbar) {
var createCollapse = function (toolbar) {
var up = h('i.fa.fa-chevron-up', {title: Messages.toolbar_collapse});
var down = h('i.fa.fa-chevron-down', {title: Messages.toolbar_expand});
var notif = h('span.cp-collapsed-notif');
@ -979,7 +977,6 @@ MessengerUI, Messages, Pages) {
if (overLimit) {
$limit.show().click(function () {
if (ApiConfig.allowSubscriptions && Config.upgradeURL) {
var key = 'pinLimitReachedAlert'; // Msg.pinLimitReachedAlert
var msg = Pages.setHTML(h('span'), Messages.pinLimitReachedAlert);
$(msg).find('a').attr({
target: '_blank',
@ -998,7 +995,7 @@ MessengerUI, Messages, Pages) {
return $limit;
};
var createNewPad = function (toolbar, config) {
var createNewPad = function (toolbar) {
var $button = Common.createButton('newpad', true);
toolbar.$drawer.append($button);
return $button;
@ -1008,7 +1005,6 @@ MessengerUI, Messages, Pages) {
if (!config.metadataMgr) {
throw new Error("You must provide a `metadataMgr` to display the user menu");
}
var metadataMgr = config.metadataMgr;
var $userAdmin = toolbar.$userAdmin.find('.'+USERADMIN_CLS).show();
var userMenuCfg = {
$initBlock: $userAdmin,
@ -1028,7 +1024,7 @@ MessengerUI, Messages, Pages) {
return $userAdmin;
};
var createMaintenance = function (toolbar, config) {
var createMaintenance = function (toolbar) {
var $notif = toolbar.$top.find('.'+MAINTENANCE_CLS);
var button = h('button.cp-maintenance-wrench.fa.fa-wrench');
$notif.append(button);

View file

@ -51,7 +51,7 @@ define([
const loadCryptPadImages = (doc) => {
return Array.from(doc .querySelectorAll('mxCell'))
.map((element) => [element, parseDrawioStyle(element.getAttribute('style'))])
.filter(([element, style]) => style && style.image && style.image.startsWith('cryptpad://'))
.filter(([, style]) => style && style.image && style.image.startsWith('cryptpad://'))
.map(([element, style]) => {
return loadImage(style.image)
.then((dataUrl) => {

View file

@ -141,7 +141,6 @@ define([
var common;
var proxy = {};
var folders = {};
var readOnly;
var startOnline = false;
var onReco;
@ -168,7 +167,7 @@ define([
}
metadataMgr.onChange(function () {
if (typeof(metadataMgr.getPrivateData().readOnly) === 'boolean') {
readOnly = APP.readOnly = metadataMgr.getPrivateData().readOnly;
APP.readOnly = metadataMgr.getPrivateData().readOnly;
privReady();
}
});
@ -200,7 +199,7 @@ define([
APP.disableSF = !privateData.enableSF && AppConfig.disableSharedFolders;
if (APP.newSharedFolder && !APP.loggedIn) {
readOnly = APP.readOnly = true;
APP.readOnly = true;
var data = folders[APP.newSharedFolder];
if (data) {
sframeChan.query('Q_SET_PAD_TITLE_IN_DRIVE', {

View file

@ -1243,14 +1243,14 @@ define([
h('i.fa.fa-plus'),
h('span', Messages.form_conditional_addAnd)
]);
var $b = $(btn).click(function () {
getConditions($container, true, rules, undefined, $b);
$(btn).click(function () {
getConditions($container, true, rules, undefined);
});
$container.append(btn);
return $b;
return;
};
var values = getConditionsValues();
getConditions = function ($container, isNew, rules, condition, $btn) {
getConditions = function ($container, isNew, rules, condition) {
condition = condition || {};
condition.uid = condition.uid || Util.uid();
@ -1272,7 +1272,7 @@ define([
if (!Array.isArray(rules)) { // new set of rules (OR)
rules = [condition];
w.push(rules);
$btn = getAddAndButton($container, rules);
getAddAndButton($container, rules);
} else {
rules.push(condition);
}
@ -1473,9 +1473,9 @@ define([
w.forEach(function (rules) {
var rulesC = h('div.cp-form-condition-rule');
var $rulesC = $(rulesC);
var $b = getAddAndButton($rulesC, rules);
getAddAndButton($rulesC, rules);
rules.forEach(function (obj) {
getConditions($rulesC, false, rules, obj, $b);
getConditions($rulesC, false, rules, obj);
});
$addC.before($rulesC);
});
@ -1585,11 +1585,11 @@ define([
if (!$v.length) { return; }
var dropV = $v[0] && $v[0].dropdown;
if (!dropV) { return; }
var res, type;
var res;
values.some(function (obj) {
if (String(obj.uid) === String(val)) {
res = obj.values;
type = obj.type;
//var type = obj.type;
return true;
}
});

View file

@ -41,8 +41,6 @@ define([
// checkboxes
var $register = $('button#register');
var registering = false;
var I_REALLY_WANT_TO_USE_MY_EMAIL_FOR_MY_USERNAME = false;
var br = function () { return h('br'); };
@ -103,9 +101,7 @@ define([
var warning = Messages._getKey('register_passwordTooShort', [
Cred.MINIMUM_PASSWORD_LENGTH
]);
return void UI.alert(warning, function () {
registering = false;
});
return void UI.alert(warning);
}
if (passwd !== confirmPassword) { // do their passwords match?
@ -156,7 +152,6 @@ define([
return true;
}
});
registering = true;
}, {
ok: Messages.register_writtenPassword,
cancel: Messages.register_cancel,

View file

@ -73,7 +73,7 @@ define([
};
var chan = makeChan();
var isNew = false;
//var isNew = false;
var checkSession = function (oldKey, cb) {
var channel = Hash.hrefToHexChannelId(Hash.hashToHref(oldKey));
var prefix = channel.slice(0,2);
@ -97,7 +97,7 @@ define([
};
chan.on('GET_SESSION', function (data, cb) {
var getHash = function () {
isNew = true;
//isNew = true;
return Hash.createRandomHash('integration');
};
var oldKey = data.key;

View file

@ -93,7 +93,6 @@ define([
var CREATE_ID = "cp-app-profile-create";
var HEADER_ID = "cp-app-profile-header";
var HEADER_RIGHT_ID = "cp-app-profile-rightside";
var CREATE_INVITE_BUTTON = 'cp-app-profile-invite-button';
var VIEW_PROFILE_BUTTON = 'cp-app-profile-viewprofile-button';
var common;

View file

@ -59,8 +59,6 @@ define([
var $register = $('button#register');
var registering = false;
var I_REALLY_WANT_TO_USE_MY_EMAIL_FOR_MY_USERNAME = false;
var br = function () { return h('br'); };
@ -96,9 +94,7 @@ define([
$uname.val(uname);
if (uname.length > Cred.MAXIMUM_NAME_LENGTH) {
let nameWarning = Messages._getKey('register_nameTooLong', [ Cred.MAXIMUM_NAME_LENGTH ]);
return void UI.alert(nameWarning, function () {
registering = false;
});
return void UI.alert(nameWarning);
}
var passwd = $passwd.val();
@ -139,9 +135,7 @@ define([
var warning = Messages._getKey('register_passwordTooShort', [
Cred.MINIMUM_PASSWORD_LENGTH
]);
return void UI.alert(warning, function () {
registering = false;
});
return void UI.alert(warning);
}
if (passwd !== confirmPassword) { // do their passwords match?
@ -174,7 +168,6 @@ define([
shouldImport,
onOTP: UI.getOTPScreen
});
registering = true;
}, {
ok: Messages.register_writtenPassword,
cancel: Messages.register_cancel,

View file

@ -16,7 +16,6 @@ define([
var ifrw;
var $modal;
var $content;
var placeholder;
var options;
var separator = '<hr data-pewpew="pezpez">';
var separatorReg = /<hr data\-pewpew="pezpez">/g;
@ -314,7 +313,7 @@ define([
$modal = Slide.$modal = $m;
$content = Slide.$content = $c;
ifrw = Slide.ifrw = window;
placeholder = Slide.placeholder = ph;
Slide.placeholder = ph;
options = Slide.options = opt;
addEvent();
addSwipeEvents();

View file

@ -1485,7 +1485,6 @@ define([
var main = function () {
var common;
var readOnly;
nThen(function (waitFor) {
$(waitFor(function () {
@ -1507,7 +1506,7 @@ define([
var privateData = metadataMgr.getPrivateData();
var user = metadataMgr.getUserData();
readOnly = driveAPP.readOnly = metadataMgr.getPrivateData().readOnly;
driveAPP.readOnly = metadataMgr.getPrivateData().readOnly;
driveAPP.loggedIn = common.isLoggedIn();
//if (!driveAPP.loggedIn) { throw new Error('NOT_LOGGED_IN'); }

View file

@ -42,9 +42,6 @@ define([
};
var Fabric = APP.Fabric = window.fabric;
var verbose = function (x) { console.log(x); };
verbose = function () {}; // comment out to enable verbose logging
var mkControls = function (framework, canvas) {
var $pickers = $('#cp-app-whiteboard-pickers');
var $colors = $('#cp-app-whiteboard-colors');