mirror of https://github.com/keeweb/keeweb.git
less underscore
This commit is contained in:
parent
3341f3e7f6
commit
731994c9fe
|
@ -1,5 +1,6 @@
|
|||
import { Launcher } from 'comp/launcher';
|
||||
import { Logger } from 'util/logger';
|
||||
import { noop } from 'util/fn';
|
||||
|
||||
const logger = new Logger('transport');
|
||||
|
||||
|
@ -18,7 +19,7 @@ const Transport = {
|
|||
fs.unlinkSync(tmpFile);
|
||||
}
|
||||
} catch (e) {
|
||||
fs.unlink(tmpFile, () => {});
|
||||
fs.unlink(tmpFile, noop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +82,7 @@ const Transport = {
|
|||
.on('error', e => {
|
||||
logger.error('Cannot GET ' + config.url, e);
|
||||
if (tmpFile) {
|
||||
fs.unlink(tmpFile, () => {});
|
||||
fs.unlink(tmpFile, noop);
|
||||
}
|
||||
config.error(e);
|
||||
});
|
||||
|
|
|
@ -6,6 +6,7 @@ import { Otp } from 'util/data/otp';
|
|||
import { Features } from 'util/features';
|
||||
import { Locale } from 'util/locale';
|
||||
import { Logger } from 'util/logger';
|
||||
import { escape } from 'util/fn';
|
||||
|
||||
const logger = new Logger('otp-qr-reader');
|
||||
|
||||
|
@ -144,7 +145,7 @@ class OtpQrReader {
|
|||
body:
|
||||
Locale.detOtpQrWrongBody +
|
||||
'<pre class="modal__pre">' +
|
||||
_.escape(err.toString()) +
|
||||
escape(err.toString()) +
|
||||
'</pre>'
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { Events } from 'framework/events';
|
||||
import { Locale } from 'util/locale';
|
||||
import { Logger } from 'util/logger';
|
||||
import { noop } from 'util/fn';
|
||||
|
||||
const logger = new Logger('launcher');
|
||||
|
||||
|
@ -84,7 +85,7 @@ const Launcher = {
|
|||
this.req('fs').exists(path, callback);
|
||||
},
|
||||
deleteFile(path, callback) {
|
||||
this.req('fs').unlink(path, callback || (() => {}));
|
||||
this.req('fs').unlink(path, callback || noop);
|
||||
},
|
||||
statFile(path, callback) {
|
||||
this.req('fs').stat(path, (err, stats) => callback(stats, err));
|
||||
|
@ -274,7 +275,7 @@ const Launcher = {
|
|||
if (cookies && cookies.length) {
|
||||
const session = this.electron().remote.session.defaultSession;
|
||||
for (const cookie of cookies) {
|
||||
session.cookies.set(cookie, () => {});
|
||||
session.cookies.set(cookie, noop);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -20,6 +20,7 @@ import { UrlFormat } from 'util/formatting/url-format';
|
|||
import { IdGenerator } from 'util/generators/id-generator';
|
||||
import { Locale } from 'util/locale';
|
||||
import { Logger } from 'util/logger';
|
||||
import { noop } from 'util/fn';
|
||||
import 'util/kdbxweb/protected-value-ex';
|
||||
|
||||
class AppModel {
|
||||
|
@ -1135,7 +1136,7 @@ class AppModel {
|
|||
this.setFileBackup(file.id, backup);
|
||||
}
|
||||
if (needBackup) {
|
||||
this.backupFile(file, data, () => {});
|
||||
this.backupFile(file, data, noop);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import { PluginCollection } from 'plugins/plugin-collection';
|
|||
import { PluginGallery } from 'plugins/plugin-gallery';
|
||||
import { SignatureVerifier } from 'util/data/signature-verifier';
|
||||
import { Logger } from 'util/logger';
|
||||
import { noop } from 'util/fn';
|
||||
|
||||
const PluginManager = Backbone.Model.extend({
|
||||
UpdateInterval: 1000 * 60 * 60 * 24 * 7,
|
||||
|
@ -181,7 +182,7 @@ const PluginManager = Backbone.Model.extend({
|
|||
const pluginId = queue.shift();
|
||||
if (pluginId) {
|
||||
return this.update(pluginId)
|
||||
.catch(() => {})
|
||||
.catch(noop)
|
||||
.then(updateNext);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { StorageBase } from 'storage/storage-base';
|
||||
import { noop } from 'util/fn';
|
||||
|
||||
const OneDriveClientId = {
|
||||
Production: '000000004818ED3A',
|
||||
|
@ -270,7 +271,7 @@ const StorageOneDrive = StorageBase.extend({
|
|||
// click the login button mentioned in #821
|
||||
const script = `const selector = '[role="button"][aria-describedby="tileError loginHeader"]';
|
||||
if (document.querySelectorAll(selector).length === 1) document.querySelector(selector).click()`;
|
||||
webContents.executeJavaScript(script).catch(() => {});
|
||||
webContents.executeJavaScript(script).catch(noop);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
import Handlebars from 'hbs';
|
||||
|
||||
const escape = Handlebars.escapeExpression;
|
||||
|
||||
export { escape };
|
||||
|
||||
export function noop() {}
|
||||
|
||||
export function shuffle(array) {
|
||||
for (let i = array.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1));
|
||||
[array[i], array[j]] = [array[j], array[i]];
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
export function pick(obj, props) {
|
||||
if (!obj) {
|
||||
return obj;
|
||||
}
|
||||
const result = {};
|
||||
for (const prop of props) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
|
||||
result[prop] = obj[prop];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function omit(obj, props) {
|
||||
if (!obj) {
|
||||
return obj;
|
||||
}
|
||||
const result = { ...obj };
|
||||
for (const prop of props) {
|
||||
delete result[prop];
|
||||
}
|
||||
return result;
|
||||
}
|
|
@ -7,6 +7,7 @@ import { Locale } from 'util/locale';
|
|||
import { Copyable } from 'framework/views/copyable';
|
||||
import { FieldViewReadOnly } from 'views/fields/field-view-read-only';
|
||||
import { FieldViewReadOnlyRaw } from 'views/fields/field-view-read-only-raw';
|
||||
import { escape } from 'util/fn';
|
||||
import template from 'templates/details/details-history.hbs';
|
||||
|
||||
class DetailsHistoryView extends View {
|
||||
|
@ -155,7 +156,7 @@ class DetailsHistoryView extends View {
|
|||
' ' +
|
||||
colorCls +
|
||||
'"></i> ' +
|
||||
_.escape(this.record.title) || '(' + Locale.detHistoryNoTitle + ')'
|
||||
escape(this.record.title) || '(' + Locale.detHistoryNoTitle + ')'
|
||||
})
|
||||
);
|
||||
this.fieldViews.push(
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { Keys } from 'const/keys';
|
||||
import { FieldViewText } from 'views/fields/field-view-text';
|
||||
import { escape } from 'util/fn';
|
||||
|
||||
class FieldViewAutocomplete extends FieldViewText {
|
||||
endEdit(newVal, extra) {
|
||||
|
@ -86,7 +87,7 @@ class FieldViewAutocomplete extends FieldViewText {
|
|||
'<div class="details__field-autocomplete-item ' +
|
||||
sel +
|
||||
'">' +
|
||||
_.escape(item) +
|
||||
escape(item) +
|
||||
'</div>'
|
||||
);
|
||||
})
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import { FieldView } from 'views/fields/field-view';
|
||||
import { escape } from 'util/fn';
|
||||
|
||||
class FieldViewReadOnly extends FieldView {
|
||||
readonly = true;
|
||||
|
||||
renderValue(value) {
|
||||
value = value.isProtected ? new Array(value.textLength + 1).join('•') : _.escape(value);
|
||||
value = value.isProtected ? new Array(value.textLength + 1).join('•') : escape(value);
|
||||
value = value.replace(/\n/g, '<br/>');
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { FieldView } from 'views/fields/field-view';
|
||||
import { escape } from 'util/fn';
|
||||
|
||||
class FieldViewSelect extends FieldView {
|
||||
readonly = true;
|
||||
|
@ -11,11 +12,11 @@ class FieldViewSelect extends FieldView {
|
|||
return (
|
||||
'<option ' +
|
||||
'value="' +
|
||||
_.escape(opt.id) +
|
||||
escape(opt.id) +
|
||||
'" ' +
|
||||
(opt.selected ? 'selected ' : '') +
|
||||
'>' +
|
||||
_.escape(opt.value) +
|
||||
escape(opt.value) +
|
||||
'</option>'
|
||||
);
|
||||
})
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { FieldViewText } from 'views/fields/field-view-text';
|
||||
import { escape } from 'util/fn';
|
||||
|
||||
class FieldViewTags extends FieldViewText {
|
||||
renderValue(value) {
|
||||
return value ? _.escape(value.join(', ')) : '';
|
||||
return value ? escape(value.join(', ')) : '';
|
||||
}
|
||||
|
||||
getEditValue(value) {
|
||||
|
@ -73,7 +74,7 @@ class FieldViewTags extends FieldViewText {
|
|||
const availableTags = this.getAvailableTags();
|
||||
const tagsHtml = availableTags
|
||||
.map(tag => {
|
||||
return '<div class="details__field-autocomplete-item">' + _.escape(tag) + '</div>';
|
||||
return '<div class="details__field-autocomplete-item">' + escape(tag) + '</div>';
|
||||
})
|
||||
.join('');
|
||||
this.tagsAutocomplete.html(tagsHtml);
|
||||
|
|
|
@ -8,6 +8,7 @@ import { PasswordGenerator } from 'util/generators/password-generator';
|
|||
import { Tip } from 'util/ui/tip';
|
||||
import { FieldView } from 'views/fields/field-view';
|
||||
import { GeneratorView } from 'views/generator-view';
|
||||
import { escape } from 'util/fn';
|
||||
|
||||
class FieldViewText extends FieldView {
|
||||
constructor(model, options) {
|
||||
|
@ -24,7 +25,7 @@ class FieldViewText extends FieldView {
|
|||
}
|
||||
return value && value.isProtected
|
||||
? PasswordGenerator.presentValueWithLineBreaks(value)
|
||||
: _.escape(value || '').replace(/\n/g, '<br/>');
|
||||
: escape(value || '').replace(/\n/g, '<br/>');
|
||||
}
|
||||
|
||||
getEditValue(value) {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { FieldViewText } from 'views/fields/field-view-text';
|
||||
import { escape } from 'util/fn';
|
||||
|
||||
class FieldViewUrl extends FieldViewText {
|
||||
displayUrlRegex = /^https:\/\//i;
|
||||
|
@ -7,9 +8,9 @@ class FieldViewUrl extends FieldViewText {
|
|||
renderValue(value) {
|
||||
return value
|
||||
? '<a href="' +
|
||||
_.escape(this.fixUrl(value)) +
|
||||
escape(this.fixUrl(value)) +
|
||||
'" rel="noreferrer noopener" target="_blank">' +
|
||||
_.escape(this.displayUrl(value)) +
|
||||
escape(this.displayUrl(value)) +
|
||||
'</a>'
|
||||
: '';
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import { Logger } from 'util/logger';
|
|||
import { InputFx } from 'util/ui/input-fx';
|
||||
import { OpenConfigView } from 'views/open-config-view';
|
||||
import { StorageFileListView } from 'views/storage-file-list-view';
|
||||
import { escape } from 'util/fn';
|
||||
import template from 'templates/open.hbs';
|
||||
|
||||
const logger = new Logger('open-view');
|
||||
|
@ -646,7 +647,7 @@ class OpenView extends View {
|
|||
body:
|
||||
Locale.openErrorDescription +
|
||||
'<pre class="modal__pre">' +
|
||||
_.escape(err.toString()) +
|
||||
escape(err.toString()) +
|
||||
'</pre>'
|
||||
});
|
||||
}
|
||||
|
@ -726,7 +727,7 @@ class OpenView extends View {
|
|||
body:
|
||||
Locale.openListErrorBody +
|
||||
'<pre class="modal__pre">' +
|
||||
_.escape(err.toString()) +
|
||||
escape(err.toString()) +
|
||||
'</pre>'
|
||||
});
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import { PasswordGenerator } from 'util/generators/password-generator';
|
|||
import { Locale } from 'util/locale';
|
||||
import { FileSaver } from 'util/ui/file-saver';
|
||||
import { OpenConfigView } from 'views/open-config-view';
|
||||
import { escape } from 'util/fn';
|
||||
import template from 'templates/settings/settings-file.hbs';
|
||||
|
||||
const DefaultBackupPath = 'Backups/{name}.{date}.bak';
|
||||
|
@ -588,7 +589,7 @@ class SettingsFileView extends View {
|
|||
body:
|
||||
description +
|
||||
'<pre class="modal__pre">' +
|
||||
_.escape(err.toString()) +
|
||||
escape(err.toString()) +
|
||||
'</pre>'
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { View } from 'framework/views/view';
|
||||
import { RuntimeInfo } from 'comp/app/runtime-info';
|
||||
import { Links } from 'const/links';
|
||||
import { escape } from 'util/fn';
|
||||
import template from 'templates/settings/settings-help.hbs';
|
||||
|
||||
class SettingsHelpView extends View {
|
||||
|
@ -28,7 +29,7 @@ class SettingsHelpView extends View {
|
|||
encodeURIComponent('!please describe your issue here!\n\n' + appInfo),
|
||||
desktopLink: Links.Desktop,
|
||||
webAppLink: Links.WebApp,
|
||||
appInfo: _.escape(appInfo)
|
||||
appInfo: escape(appInfo)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue