mirror of https://github.com/keeweb/keeweb
up modules; prettier
This commit is contained in:
parent
09fd37820b
commit
e0b65bbebf
|
@ -10,7 +10,7 @@ const pkg = require('./package.json');
|
|||
|
||||
debug.enable('electron-notarize');
|
||||
|
||||
module.exports = function(grunt) {
|
||||
module.exports = function (grunt) {
|
||||
require('time-grunt')(grunt);
|
||||
require('load-grunt-tasks')(grunt);
|
||||
|
||||
|
|
|
@ -1,27 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Not Found</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: -apple-system, "BlinkMacSystemFont", "Raleway", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
|
||||
font-feature-settings: "liga" 0;
|
||||
text-align: center;
|
||||
background: #F5F5F5;
|
||||
font-weight: 300;
|
||||
}
|
||||
h1 {
|
||||
font-size: 3em;
|
||||
margin-top: 10vh;
|
||||
}
|
||||
p {
|
||||
line-height: 1.5em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>404 Not Found</h1>
|
||||
<p>Sorry, the page you're looking for was not found.</p>
|
||||
</body>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Not Found</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: -apple-system, 'BlinkMacSystemFont', 'Raleway', 'Helvetica Neue',
|
||||
'Helvetica', 'Arial', sans-serif;
|
||||
font-feature-settings: 'liga' 0;
|
||||
text-align: center;
|
||||
background: #f5f5f5;
|
||||
font-weight: 300;
|
||||
}
|
||||
h1 {
|
||||
font-size: 3em;
|
||||
margin-top: 10vh;
|
||||
}
|
||||
p {
|
||||
line-height: 1.5em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>404 Not Found</h1>
|
||||
<p>Sorry, the page you're looking for was not found.</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -46,7 +46,7 @@ ready(() => {
|
|||
.then(initStorage)
|
||||
.then(showApp)
|
||||
.then(postInit)
|
||||
.catch(e => {
|
||||
.catch((e) => {
|
||||
appModel.appLogger.error('Error starting app', e);
|
||||
});
|
||||
|
||||
|
@ -57,7 +57,7 @@ ready(() => {
|
|||
);
|
||||
}
|
||||
return FeatureTester.test()
|
||||
.catch(e => {
|
||||
.catch((e) => {
|
||||
Alerts.error({
|
||||
header: Locale.appSettingsError,
|
||||
body: Locale.appNotSupportedError,
|
||||
|
@ -119,7 +119,7 @@ ready(() => {
|
|||
.then(() => {
|
||||
SettingsManager.setBySettings(appModel.settings);
|
||||
})
|
||||
.catch(e => {
|
||||
.catch((e) => {
|
||||
if (!appModel.settings.cacheConfigSettings) {
|
||||
showSettingsLoadError();
|
||||
throw e;
|
||||
|
@ -146,7 +146,7 @@ ready(() => {
|
|||
const protocolIsInsecure = ['https:', 'file:', 'app:'].indexOf(location.protocol) < 0;
|
||||
const hostIsInsecure = location.hostname !== 'localhost';
|
||||
if (protocolIsInsecure && hostIsInsecure && !skipHttpsWarning) {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve) => {
|
||||
Alerts.error({
|
||||
header: Locale.appSecWarn,
|
||||
icon: 'user-secret',
|
||||
|
@ -163,7 +163,7 @@ ready(() => {
|
|||
});
|
||||
} else {
|
||||
showView();
|
||||
return new Promise(resolve => requestAnimationFrame(resolve));
|
||||
return new Promise((resolve) => requestAnimationFrame(resolve));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import { Ranking } from 'util/data/ranking';
|
|||
|
||||
const urlPartsRegex = /^(\w+:\/\/)?(?:(?:www|wwws|secure)\.)?([^\/]+)\/?(.*)/;
|
||||
|
||||
const AutoTypeFilter = function(windowInfo, appModel) {
|
||||
const AutoTypeFilter = function (windowInfo, appModel) {
|
||||
this.title = windowInfo.title;
|
||||
this.url = windowInfo.url;
|
||||
this.text = '';
|
||||
|
@ -11,34 +11,34 @@ const AutoTypeFilter = function(windowInfo, appModel) {
|
|||
this.appModel = appModel;
|
||||
};
|
||||
|
||||
AutoTypeFilter.prototype.getEntries = function() {
|
||||
AutoTypeFilter.prototype.getEntries = function () {
|
||||
const filter = {
|
||||
text: this.text,
|
||||
autoType: true
|
||||
};
|
||||
this.prepareFilter();
|
||||
let entries = this.appModel.getEntriesByFilter(filter).map(e => [e, this.getEntryRank(e)]);
|
||||
let entries = this.appModel.getEntriesByFilter(filter).map((e) => [e, this.getEntryRank(e)]);
|
||||
if (!this.ignoreWindowInfo) {
|
||||
entries = entries.filter(e => e[1]);
|
||||
entries = entries.filter((e) => e[1]);
|
||||
}
|
||||
entries = entries.sort((x, y) =>
|
||||
x[1] === y[1] ? x[0].title.localeCompare(y[0].title) : y[1] - x[1]
|
||||
);
|
||||
entries = entries.map(p => p[0]);
|
||||
entries = entries.map((p) => p[0]);
|
||||
return new SearchResultCollection(entries, { comparator: 'none' });
|
||||
};
|
||||
|
||||
AutoTypeFilter.prototype.hasWindowInfo = function() {
|
||||
AutoTypeFilter.prototype.hasWindowInfo = function () {
|
||||
return this.title || this.url;
|
||||
};
|
||||
|
||||
AutoTypeFilter.prototype.prepareFilter = function() {
|
||||
AutoTypeFilter.prototype.prepareFilter = function () {
|
||||
this.titleLower = this.title ? this.title.toLowerCase() : null;
|
||||
this.urlLower = this.url ? this.url.toLowerCase() : null;
|
||||
this.urlParts = this.url ? urlPartsRegex.exec(this.urlLower) : null;
|
||||
};
|
||||
|
||||
AutoTypeFilter.prototype.getEntryRank = function(entry) {
|
||||
AutoTypeFilter.prototype.getEntryRank = function (entry) {
|
||||
let rank = 0;
|
||||
if (this.titleLower && entry.title) {
|
||||
rank += Ranking.getStringRank(entry.title.toLowerCase(), this.titleLower);
|
||||
|
|
|
@ -11,7 +11,7 @@ const MaxSteps = 1000;
|
|||
const MaxCopy = 2;
|
||||
const FakeCharAlphabet = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz123456789O0oIl';
|
||||
|
||||
const AutoTypeObfuscator = function(chars) {
|
||||
const AutoTypeObfuscator = function (chars) {
|
||||
this.chars = chars;
|
||||
this.inputChars = [];
|
||||
this.inputCursor = 0;
|
||||
|
@ -21,7 +21,7 @@ const AutoTypeObfuscator = function(chars) {
|
|||
this.copyCount = 0;
|
||||
};
|
||||
|
||||
AutoTypeObfuscator.prototype.obfuscate = function() {
|
||||
AutoTypeObfuscator.prototype.obfuscate = function () {
|
||||
while (!this.finished()) {
|
||||
this.step();
|
||||
if (this.stepCount++ > MaxSteps) {
|
||||
|
@ -35,16 +35,16 @@ AutoTypeObfuscator.prototype.obfuscate = function() {
|
|||
return this.ops;
|
||||
};
|
||||
|
||||
AutoTypeObfuscator.prototype.finished = function() {
|
||||
AutoTypeObfuscator.prototype.finished = function () {
|
||||
return (
|
||||
this.chars.length === this.inputChars.length &&
|
||||
this.chars.every(function(ch, ix) {
|
||||
this.chars.every(function (ch, ix) {
|
||||
return this.inputChars[ix].ch === ch;
|
||||
}, this)
|
||||
);
|
||||
};
|
||||
|
||||
AutoTypeObfuscator.prototype.step = function() {
|
||||
AutoTypeObfuscator.prototype.step = function () {
|
||||
const isFake = this.stepCount < MaxFakeOps && Math.random() > this.stepCount / MaxFakeOps;
|
||||
if (isFake) {
|
||||
this.stepFake();
|
||||
|
@ -52,11 +52,11 @@ AutoTypeObfuscator.prototype.step = function() {
|
|||
this.stepReal();
|
||||
}
|
||||
if (logger.getLevel() >= Logger.Level.Debug) {
|
||||
logger.debug('value', this.inputChars.map(ic => ic.ch).join(''));
|
||||
logger.debug('value', this.inputChars.map((ic) => ic.ch).join(''));
|
||||
}
|
||||
};
|
||||
|
||||
AutoTypeObfuscator.prototype.stepFake = function() {
|
||||
AutoTypeObfuscator.prototype.stepFake = function () {
|
||||
const pos = Math.floor(Math.random() * (this.inputChars.length + 1));
|
||||
const ch = FakeCharAlphabet[Math.floor(Math.random() * FakeCharAlphabet.length)];
|
||||
logger.info('step.fake', pos, ch);
|
||||
|
@ -85,7 +85,7 @@ AutoTypeObfuscator.prototype.stepFake = function() {
|
|||
}
|
||||
};
|
||||
|
||||
AutoTypeObfuscator.prototype.stepReal = function() {
|
||||
AutoTypeObfuscator.prototype.stepReal = function () {
|
||||
const possibleActions = [];
|
||||
const inputRealPositions = [];
|
||||
let i;
|
||||
|
@ -134,7 +134,7 @@ AutoTypeObfuscator.prototype.stepReal = function() {
|
|||
}
|
||||
};
|
||||
|
||||
AutoTypeObfuscator.prototype.moveToPos = function(pos) {
|
||||
AutoTypeObfuscator.prototype.moveToPos = function (pos) {
|
||||
logger.debug('moveToPos', pos);
|
||||
while (this.inputCursor > pos) {
|
||||
this.moveLeft();
|
||||
|
@ -144,21 +144,21 @@ AutoTypeObfuscator.prototype.moveToPos = function(pos) {
|
|||
}
|
||||
};
|
||||
|
||||
AutoTypeObfuscator.prototype.moveLeft = function() {
|
||||
AutoTypeObfuscator.prototype.moveLeft = function () {
|
||||
logger.debug('moveLeft');
|
||||
this.ops.push({ type: 'key', value: 'left' });
|
||||
this.inputCursor--;
|
||||
this.inputSel = 0;
|
||||
};
|
||||
|
||||
AutoTypeObfuscator.prototype.moveRight = function() {
|
||||
AutoTypeObfuscator.prototype.moveRight = function () {
|
||||
logger.debug('moveRight');
|
||||
this.ops.push({ type: 'key', value: 'right' });
|
||||
this.inputCursor++;
|
||||
this.inputSel = 0;
|
||||
};
|
||||
|
||||
AutoTypeObfuscator.prototype.inputChar = function(ch) {
|
||||
AutoTypeObfuscator.prototype.inputChar = function (ch) {
|
||||
logger.debug('inputChar', ch);
|
||||
this.ops.push({ type: 'text', value: ch });
|
||||
this.inputChars.splice(this.inputCursor, this.inputSel, { ch });
|
||||
|
@ -166,7 +166,7 @@ AutoTypeObfuscator.prototype.inputChar = function(ch) {
|
|||
this.inputSel = 0;
|
||||
};
|
||||
|
||||
AutoTypeObfuscator.prototype.copyPaste = function(ch) {
|
||||
AutoTypeObfuscator.prototype.copyPaste = function (ch) {
|
||||
logger.debug('copyPaste', ch);
|
||||
this.ops.push({ type: 'cmd', value: 'copyPaste', arg: ch });
|
||||
this.inputChars.splice(this.inputCursor, this.inputSel, { ch });
|
||||
|
@ -174,7 +174,7 @@ AutoTypeObfuscator.prototype.copyPaste = function(ch) {
|
|||
this.inputSel = 0;
|
||||
};
|
||||
|
||||
AutoTypeObfuscator.prototype.selectText = function(backward, count) {
|
||||
AutoTypeObfuscator.prototype.selectText = function (backward, count) {
|
||||
logger.debug('selectText', backward ? 'left' : 'right', count);
|
||||
const ops = [];
|
||||
for (let i = 0; i < count; i++) {
|
||||
|
@ -192,7 +192,7 @@ AutoTypeObfuscator.prototype.selectText = function(backward, count) {
|
|||
this.inputSel = count;
|
||||
};
|
||||
|
||||
AutoTypeObfuscator.prototype.deleteText = function(backward) {
|
||||
AutoTypeObfuscator.prototype.deleteText = function (backward) {
|
||||
logger.debug('deleteText', backward ? 'left' : 'right');
|
||||
this.ops.push({ type: 'key', value: backward ? 'bs' : 'del' });
|
||||
if (this.inputSel) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { AutoTypeRunner } from 'auto-type/auto-type-runner';
|
||||
|
||||
const AutoTypeParser = function(sequence) {
|
||||
const AutoTypeParser = function (sequence) {
|
||||
this.sequence = sequence;
|
||||
this.ix = 0;
|
||||
this.states = [];
|
||||
|
@ -8,7 +8,7 @@ const AutoTypeParser = function(sequence) {
|
|||
|
||||
AutoTypeParser.opRegex = /^(.*?)(?:([\s:=])[\s:=]*(.*))?$/;
|
||||
|
||||
AutoTypeParser.prototype.parse = function() {
|
||||
AutoTypeParser.prototype.parse = function () {
|
||||
const len = this.sequence.length;
|
||||
this.pushState();
|
||||
while (this.ix < len) {
|
||||
|
@ -45,14 +45,14 @@ AutoTypeParser.prototype.parse = function() {
|
|||
return new AutoTypeRunner(this.state().ops);
|
||||
};
|
||||
|
||||
AutoTypeParser.prototype.pushState = function() {
|
||||
AutoTypeParser.prototype.pushState = function () {
|
||||
this.states.unshift({
|
||||
modifiers: null,
|
||||
ops: []
|
||||
});
|
||||
};
|
||||
|
||||
AutoTypeParser.prototype.popState = function() {
|
||||
AutoTypeParser.prototype.popState = function () {
|
||||
if (this.states.length <= 1) {
|
||||
throw 'Unexpected ")" at index ' + this.ix;
|
||||
}
|
||||
|
@ -60,11 +60,11 @@ AutoTypeParser.prototype.popState = function() {
|
|||
this.addState(state);
|
||||
};
|
||||
|
||||
AutoTypeParser.prototype.state = function() {
|
||||
AutoTypeParser.prototype.state = function () {
|
||||
return this.states[0];
|
||||
};
|
||||
|
||||
AutoTypeParser.prototype.readOp = function() {
|
||||
AutoTypeParser.prototype.readOp = function () {
|
||||
const toIx = this.sequence.indexOf('}', this.ix + 2);
|
||||
if (toIx < 0) {
|
||||
throw 'Mismatched "{" at index ' + this.ix;
|
||||
|
@ -79,7 +79,7 @@ AutoTypeParser.prototype.readOp = function() {
|
|||
this.addOp(op, sep, arg);
|
||||
};
|
||||
|
||||
AutoTypeParser.prototype.readModifier = function(modifier) {
|
||||
AutoTypeParser.prototype.readModifier = function (modifier) {
|
||||
const state = this.state();
|
||||
if (!state.modifiers) {
|
||||
state.modifiers = {};
|
||||
|
@ -91,14 +91,14 @@ AutoTypeParser.prototype.readModifier = function(modifier) {
|
|||
state.modifiers[modifier] = true;
|
||||
};
|
||||
|
||||
AutoTypeParser.prototype.resetModifiers = function() {
|
||||
AutoTypeParser.prototype.resetModifiers = function () {
|
||||
const state = this.state();
|
||||
const modifiers = state.modifiers;
|
||||
state.modifiers = null;
|
||||
return modifiers;
|
||||
};
|
||||
|
||||
AutoTypeParser.prototype.addState = function(state) {
|
||||
AutoTypeParser.prototype.addState = function (state) {
|
||||
this.state().ops.push({
|
||||
type: 'group',
|
||||
value: state.ops,
|
||||
|
@ -106,7 +106,7 @@ AutoTypeParser.prototype.addState = function(state) {
|
|||
});
|
||||
};
|
||||
|
||||
AutoTypeParser.prototype.addChar = function(ch) {
|
||||
AutoTypeParser.prototype.addChar = function (ch) {
|
||||
this.state().ops.push({
|
||||
type: 'text',
|
||||
value: ch,
|
||||
|
@ -114,7 +114,7 @@ AutoTypeParser.prototype.addChar = function(ch) {
|
|||
});
|
||||
};
|
||||
|
||||
AutoTypeParser.prototype.addOp = function(op, sep, arg) {
|
||||
AutoTypeParser.prototype.addOp = function (op, sep, arg) {
|
||||
this.state().ops.push({
|
||||
type: 'op',
|
||||
value: op,
|
||||
|
|
|
@ -9,7 +9,7 @@ const emitterLogger = new Logger(
|
|||
localStorage.debugAutoType ? Logger.Level.All : Logger.Level.Warn
|
||||
);
|
||||
|
||||
const AutoTypeRunner = function(ops) {
|
||||
const AutoTypeRunner = function (ops) {
|
||||
this.ops = ops;
|
||||
this.pendingResolvesCount = 0;
|
||||
this.entry = null;
|
||||
|
@ -142,7 +142,7 @@ AutoTypeRunner.Substitutions = {
|
|||
}
|
||||
};
|
||||
|
||||
AutoTypeRunner.prototype.resolve = function(entry, context, callback) {
|
||||
AutoTypeRunner.prototype.resolve = function (entry, context, callback) {
|
||||
this.entry = entry;
|
||||
this.context = context;
|
||||
try {
|
||||
|
@ -157,7 +157,7 @@ AutoTypeRunner.prototype.resolve = function(entry, context, callback) {
|
|||
}
|
||||
};
|
||||
|
||||
AutoTypeRunner.prototype.resolveOps = function(ops) {
|
||||
AutoTypeRunner.prototype.resolveOps = function (ops) {
|
||||
for (let i = 0, len = ops.length; i < len; i++) {
|
||||
const op = ops[i];
|
||||
if (op.type === 'group') {
|
||||
|
@ -168,7 +168,7 @@ AutoTypeRunner.prototype.resolveOps = function(ops) {
|
|||
}
|
||||
};
|
||||
|
||||
AutoTypeRunner.prototype.resolveOp = function(op) {
|
||||
AutoTypeRunner.prototype.resolveOp = function (op) {
|
||||
if (op.value.length === 1 && !op.sep) {
|
||||
// {x}
|
||||
op.type = 'text';
|
||||
|
@ -224,7 +224,7 @@ AutoTypeRunner.prototype.resolveOp = function(op) {
|
|||
}
|
||||
};
|
||||
|
||||
AutoTypeRunner.prototype.tryParseCommand = function(op) {
|
||||
AutoTypeRunner.prototype.tryParseCommand = function (op) {
|
||||
switch (op.value.toLowerCase()) {
|
||||
case 'clearfield':
|
||||
// {CLEARFIELD}
|
||||
|
@ -263,7 +263,7 @@ AutoTypeRunner.prototype.tryParseCommand = function(op) {
|
|||
}
|
||||
};
|
||||
|
||||
AutoTypeRunner.prototype.getEntryFieldKeys = function(field, op) {
|
||||
AutoTypeRunner.prototype.getEntryFieldKeys = function (field, op) {
|
||||
if (!field || !this.entry) {
|
||||
return '';
|
||||
}
|
||||
|
@ -274,7 +274,7 @@ AutoTypeRunner.prototype.getEntryFieldKeys = function(field, op) {
|
|||
if (value.isProtected) {
|
||||
op.type = 'group';
|
||||
const ops = [];
|
||||
value.forEachChar(ch => {
|
||||
value.forEachChar((ch) => {
|
||||
if (ch === 10 || ch === 13) {
|
||||
ops.push({ type: 'key', value: 'enter' });
|
||||
} else {
|
||||
|
@ -289,7 +289,7 @@ AutoTypeRunner.prototype.getEntryFieldKeys = function(field, op) {
|
|||
}
|
||||
op.type = 'group';
|
||||
const partsOps = [];
|
||||
parts.forEach(part => {
|
||||
parts.forEach((part) => {
|
||||
if (partsOps.length) {
|
||||
partsOps.push({ type: 'key', value: 'enter' });
|
||||
}
|
||||
|
@ -301,11 +301,11 @@ AutoTypeRunner.prototype.getEntryFieldKeys = function(field, op) {
|
|||
}
|
||||
};
|
||||
|
||||
AutoTypeRunner.prototype.getEntryGroupName = function() {
|
||||
AutoTypeRunner.prototype.getEntryGroupName = function () {
|
||||
return this.entry && this.entry.group.title;
|
||||
};
|
||||
|
||||
AutoTypeRunner.prototype.dt = function(part) {
|
||||
AutoTypeRunner.prototype.dt = function (part) {
|
||||
switch (part) {
|
||||
case 'simple':
|
||||
return (
|
||||
|
@ -333,7 +333,7 @@ AutoTypeRunner.prototype.dt = function(part) {
|
|||
}
|
||||
};
|
||||
|
||||
AutoTypeRunner.prototype.udt = function(part) {
|
||||
AutoTypeRunner.prototype.udt = function (part) {
|
||||
switch (part) {
|
||||
case 'simple':
|
||||
return (
|
||||
|
@ -361,7 +361,7 @@ AutoTypeRunner.prototype.udt = function(part) {
|
|||
}
|
||||
};
|
||||
|
||||
AutoTypeRunner.prototype.getOtp = function(op) {
|
||||
AutoTypeRunner.prototype.getOtp = function (op) {
|
||||
if (!this.entry) {
|
||||
return '';
|
||||
}
|
||||
|
@ -375,7 +375,7 @@ AutoTypeRunner.prototype.getOtp = function(op) {
|
|||
return AutoTypeRunner.PendingResolve;
|
||||
};
|
||||
|
||||
AutoTypeRunner.prototype.pendingResolved = function(op, value, error) {
|
||||
AutoTypeRunner.prototype.pendingResolved = function (op, value, error) {
|
||||
const wasPending = op.value === AutoTypeRunner.PendingResolve;
|
||||
if (value) {
|
||||
op.value = value;
|
||||
|
@ -390,11 +390,11 @@ AutoTypeRunner.prototype.pendingResolved = function(op, value, error) {
|
|||
}
|
||||
};
|
||||
|
||||
AutoTypeRunner.prototype.obfuscate = function() {
|
||||
AutoTypeRunner.prototype.obfuscate = function () {
|
||||
this.obfuscateOps(this.ops);
|
||||
};
|
||||
|
||||
AutoTypeRunner.prototype.obfuscateOps = function(ops) {
|
||||
AutoTypeRunner.prototype.obfuscateOps = function (ops) {
|
||||
for (let i = 0, len = ops.length; i < len; i++) {
|
||||
const op = ops[i];
|
||||
if (op.mod) {
|
||||
|
@ -403,7 +403,7 @@ AutoTypeRunner.prototype.obfuscateOps = function(ops) {
|
|||
if (op.type === 'text') {
|
||||
this.obfuscateOp(op);
|
||||
} else if (op.type === 'group') {
|
||||
const onlyText = op.value.every(grOp => grOp.type === 'text' && !grOp.mod);
|
||||
const onlyText = op.value.every((grOp) => grOp.type === 'text' && !grOp.mod);
|
||||
if (onlyText) {
|
||||
this.obfuscateOp(op);
|
||||
} else {
|
||||
|
@ -413,7 +413,7 @@ AutoTypeRunner.prototype.obfuscateOps = function(ops) {
|
|||
}
|
||||
};
|
||||
|
||||
AutoTypeRunner.prototype.obfuscateOp = function(op) {
|
||||
AutoTypeRunner.prototype.obfuscateOp = function (op) {
|
||||
let letters = [];
|
||||
if (op.type === 'text') {
|
||||
if (!op.value || op.value.length <= 1) {
|
||||
|
@ -421,7 +421,7 @@ AutoTypeRunner.prototype.obfuscateOp = function(op) {
|
|||
}
|
||||
letters = op.value.split('');
|
||||
} else {
|
||||
op.value.forEach(grOp => letters.push(...grOp.value.split('')));
|
||||
op.value.forEach((grOp) => letters.push(...grOp.value.split('')));
|
||||
}
|
||||
if (letters.length <= 1) {
|
||||
return;
|
||||
|
@ -431,7 +431,7 @@ AutoTypeRunner.prototype.obfuscateOp = function(op) {
|
|||
op.type = 'group';
|
||||
};
|
||||
|
||||
AutoTypeRunner.prototype.run = function(callback, windowId) {
|
||||
AutoTypeRunner.prototype.run = function (callback, windowId) {
|
||||
this.emitter = AutoTypeEmitterFactory.create(this.emitNext.bind(this), windowId);
|
||||
this.emitterState = {
|
||||
callback,
|
||||
|
@ -445,7 +445,7 @@ AutoTypeRunner.prototype.run = function(callback, windowId) {
|
|||
this.emitNext();
|
||||
};
|
||||
|
||||
AutoTypeRunner.prototype.emitNext = function(err) {
|
||||
AutoTypeRunner.prototype.emitNext = function (err) {
|
||||
if (err) {
|
||||
this.emitterState.finished = true;
|
||||
this.emitterState.callback(err);
|
||||
|
@ -518,8 +518,8 @@ AutoTypeRunner.prototype.emitNext = function(err) {
|
|||
}
|
||||
};
|
||||
|
||||
AutoTypeRunner.prototype.setEmitterMod = function(addedMod) {
|
||||
Object.keys(addedMod).forEach(function(mod) {
|
||||
AutoTypeRunner.prototype.setEmitterMod = function (addedMod) {
|
||||
Object.keys(addedMod).forEach(function (mod) {
|
||||
if (addedMod[mod] && !this.emitterState.activeMod[mod]) {
|
||||
emitterLogger.debug('mod', mod, true);
|
||||
this.emitter.setMod(mod, true);
|
||||
|
@ -528,8 +528,8 @@ AutoTypeRunner.prototype.setEmitterMod = function(addedMod) {
|
|||
}, this);
|
||||
};
|
||||
|
||||
AutoTypeRunner.prototype.resetEmitterMod = function(targetState) {
|
||||
Object.keys(this.emitterState.activeMod).forEach(function(mod) {
|
||||
AutoTypeRunner.prototype.resetEmitterMod = function (targetState) {
|
||||
Object.keys(this.emitterState.activeMod).forEach(function (mod) {
|
||||
if (this.emitterState.activeMod[mod] && !targetState[mod]) {
|
||||
emitterLogger.debug('mod', mod, false);
|
||||
this.emitter.setMod(mod, false);
|
||||
|
|
|
@ -59,13 +59,13 @@ const ModMap = {
|
|||
'^^': '^'
|
||||
};
|
||||
|
||||
const AutoTypeEmitter = function(callback) {
|
||||
const AutoTypeEmitter = function (callback) {
|
||||
this.callback = callback;
|
||||
this.mod = {};
|
||||
this.pendingScript = [];
|
||||
};
|
||||
|
||||
AutoTypeEmitter.prototype.setMod = function(mod, enabled) {
|
||||
AutoTypeEmitter.prototype.setMod = function (mod, enabled) {
|
||||
if (enabled) {
|
||||
this.mod[ModMap[mod]] = true;
|
||||
} else {
|
||||
|
@ -73,12 +73,12 @@ AutoTypeEmitter.prototype.setMod = function(mod, enabled) {
|
|||
}
|
||||
};
|
||||
|
||||
AutoTypeEmitter.prototype.text = function(text) {
|
||||
AutoTypeEmitter.prototype.text = function (text) {
|
||||
this.pendingScript.push('text ' + this.modString() + ' ' + text);
|
||||
this.callback();
|
||||
};
|
||||
|
||||
AutoTypeEmitter.prototype.key = function(key) {
|
||||
AutoTypeEmitter.prototype.key = function (key) {
|
||||
if (typeof key !== 'number') {
|
||||
if (!KeyMap[key]) {
|
||||
return this.callback('Bad key: ' + key);
|
||||
|
@ -89,17 +89,17 @@ AutoTypeEmitter.prototype.key = function(key) {
|
|||
this.callback();
|
||||
};
|
||||
|
||||
AutoTypeEmitter.prototype.copyPaste = function(text) {
|
||||
AutoTypeEmitter.prototype.copyPaste = function (text) {
|
||||
this.pendingScript.push('copypaste ' + text);
|
||||
this.callback();
|
||||
};
|
||||
|
||||
AutoTypeEmitter.prototype.wait = function(time) {
|
||||
AutoTypeEmitter.prototype.wait = function (time) {
|
||||
this.pendingScript.push('wait ' + time);
|
||||
this.callback();
|
||||
};
|
||||
|
||||
AutoTypeEmitter.prototype.waitComplete = function() {
|
||||
AutoTypeEmitter.prototype.waitComplete = function () {
|
||||
if (this.pendingScript.length) {
|
||||
const script = this.pendingScript.join('\n');
|
||||
this.pendingScript.length = 0;
|
||||
|
@ -109,16 +109,16 @@ AutoTypeEmitter.prototype.waitComplete = function() {
|
|||
}
|
||||
};
|
||||
|
||||
AutoTypeEmitter.prototype.setDelay = function(delay) {
|
||||
AutoTypeEmitter.prototype.setDelay = function (delay) {
|
||||
this.delay = delay || 0;
|
||||
this.callback('Not implemented');
|
||||
};
|
||||
|
||||
AutoTypeEmitter.prototype.modString = function() {
|
||||
AutoTypeEmitter.prototype.modString = function () {
|
||||
return Object.keys(this.mod).join('');
|
||||
};
|
||||
|
||||
AutoTypeEmitter.prototype.runScript = function(script) {
|
||||
AutoTypeEmitter.prototype.runScript = function (script) {
|
||||
Launcher.spawn({
|
||||
cmd: AutoTypeNativeHelper.getHelperPath(),
|
||||
data: script,
|
||||
|
|
|
@ -59,7 +59,7 @@ const ModMap = {
|
|||
'^^': 'ctrl'
|
||||
};
|
||||
|
||||
const AutoTypeEmitter = function(callback, windowId) {
|
||||
const AutoTypeEmitter = function (callback, windowId) {
|
||||
this.callback = callback;
|
||||
if (typeof windowId !== 'undefined' && windowId) {
|
||||
this.windowParameter = '--window ' + windowId + ' ';
|
||||
|
@ -70,7 +70,7 @@ const AutoTypeEmitter = function(callback, windowId) {
|
|||
this.pendingScript = [];
|
||||
};
|
||||
|
||||
AutoTypeEmitter.prototype.setMod = function(mod, enabled) {
|
||||
AutoTypeEmitter.prototype.setMod = function (mod, enabled) {
|
||||
if (enabled) {
|
||||
this.mod[ModMap[mod]] = true;
|
||||
} else {
|
||||
|
@ -78,23 +78,23 @@ AutoTypeEmitter.prototype.setMod = function(mod, enabled) {
|
|||
}
|
||||
};
|
||||
|
||||
AutoTypeEmitter.prototype.text = function(text) {
|
||||
AutoTypeEmitter.prototype.text = function (text) {
|
||||
this.pendingScript.push('keyup ctrl alt shift t');
|
||||
Object.keys(this.mod).forEach(mod => {
|
||||
Object.keys(this.mod).forEach((mod) => {
|
||||
this.pendingScript.push('keydown ' + this.windowParameter + ModMap[mod]);
|
||||
});
|
||||
text.split('').forEach(char => {
|
||||
text.split('').forEach((char) => {
|
||||
this.pendingScript.push(
|
||||
'key ' + this.windowParameter + 'U' + char.charCodeAt(0).toString(16)
|
||||
);
|
||||
});
|
||||
Object.keys(this.mod).forEach(mod => {
|
||||
Object.keys(this.mod).forEach((mod) => {
|
||||
this.pendingScript.push('keyup ' + this.windowParameter + ModMap[mod]);
|
||||
});
|
||||
this.waitComplete();
|
||||
};
|
||||
|
||||
AutoTypeEmitter.prototype.key = function(key) {
|
||||
AutoTypeEmitter.prototype.key = function (key) {
|
||||
const isSpecialKey = typeof key !== 'number';
|
||||
if (isSpecialKey) {
|
||||
if (!KeyMap[key]) {
|
||||
|
@ -112,7 +112,7 @@ AutoTypeEmitter.prototype.key = function(key) {
|
|||
}
|
||||
};
|
||||
|
||||
AutoTypeEmitter.prototype.copyPaste = function(text) {
|
||||
AutoTypeEmitter.prototype.copyPaste = function (text) {
|
||||
this.pendingScript.push('sleep 0.5');
|
||||
Launcher.setClipboardText(text);
|
||||
this.pendingScript.push('key --clearmodifiers ' + this.windowParameter + 'shift+Insert');
|
||||
|
@ -120,12 +120,12 @@ AutoTypeEmitter.prototype.copyPaste = function(text) {
|
|||
this.waitComplete();
|
||||
};
|
||||
|
||||
AutoTypeEmitter.prototype.wait = function(time) {
|
||||
AutoTypeEmitter.prototype.wait = function (time) {
|
||||
this.pendingScript.push('sleep ' + time / 1000);
|
||||
this.callback();
|
||||
};
|
||||
|
||||
AutoTypeEmitter.prototype.waitComplete = function(callback) {
|
||||
AutoTypeEmitter.prototype.waitComplete = function (callback) {
|
||||
if (this.pendingScript.length) {
|
||||
const script = this.pendingScript.join(' ');
|
||||
this.pendingScript.length = 0;
|
||||
|
@ -135,15 +135,15 @@ AutoTypeEmitter.prototype.waitComplete = function(callback) {
|
|||
}
|
||||
};
|
||||
|
||||
AutoTypeEmitter.prototype.modString = function() {
|
||||
AutoTypeEmitter.prototype.modString = function () {
|
||||
let mod = '';
|
||||
Object.keys(this.mod).forEach(key => {
|
||||
Object.keys(this.mod).forEach((key) => {
|
||||
mod += key + '+';
|
||||
});
|
||||
return mod;
|
||||
};
|
||||
|
||||
AutoTypeEmitter.prototype.runScript = function(script, callback) {
|
||||
AutoTypeEmitter.prototype.runScript = function (script, callback) {
|
||||
Launcher.spawn({
|
||||
cmd: 'xdotool',
|
||||
args: ['-'],
|
||||
|
|
|
@ -59,13 +59,13 @@ const ModMap = {
|
|||
'^^': '^'
|
||||
};
|
||||
|
||||
const AutoTypeEmitter = function(callback) {
|
||||
const AutoTypeEmitter = function (callback) {
|
||||
this.callback = callback;
|
||||
this.mod = {};
|
||||
this.pendingScript = [];
|
||||
};
|
||||
|
||||
AutoTypeEmitter.prototype.setMod = function(mod, enabled) {
|
||||
AutoTypeEmitter.prototype.setMod = function (mod, enabled) {
|
||||
if (enabled) {
|
||||
this.mod[ModMap[mod]] = true;
|
||||
} else {
|
||||
|
@ -73,14 +73,14 @@ AutoTypeEmitter.prototype.setMod = function(mod, enabled) {
|
|||
}
|
||||
};
|
||||
|
||||
AutoTypeEmitter.prototype.text = function(text) {
|
||||
AutoTypeEmitter.prototype.text = function (text) {
|
||||
if (text) {
|
||||
this.pendingScript.push('text ' + this.modStr() + ' ' + text);
|
||||
}
|
||||
this.callback();
|
||||
};
|
||||
|
||||
AutoTypeEmitter.prototype.key = function(key) {
|
||||
AutoTypeEmitter.prototype.key = function (key) {
|
||||
if (typeof key !== 'number') {
|
||||
if (!KeyMap[key]) {
|
||||
return this.callback('Bad key: ' + key);
|
||||
|
@ -91,17 +91,17 @@ AutoTypeEmitter.prototype.key = function(key) {
|
|||
this.callback();
|
||||
};
|
||||
|
||||
AutoTypeEmitter.prototype.copyPaste = function(text) {
|
||||
AutoTypeEmitter.prototype.copyPaste = function (text) {
|
||||
this.pendingScript.push('copypaste ' + text);
|
||||
this.callback();
|
||||
};
|
||||
|
||||
AutoTypeEmitter.prototype.wait = function(time) {
|
||||
AutoTypeEmitter.prototype.wait = function (time) {
|
||||
this.pendingScript.push('wait ' + time);
|
||||
this.callback();
|
||||
};
|
||||
|
||||
AutoTypeEmitter.prototype.waitComplete = function() {
|
||||
AutoTypeEmitter.prototype.waitComplete = function () {
|
||||
if (this.pendingScript.length) {
|
||||
const script = this.pendingScript.join('\n');
|
||||
this.pendingScript.length = 0;
|
||||
|
@ -111,16 +111,16 @@ AutoTypeEmitter.prototype.waitComplete = function() {
|
|||
}
|
||||
};
|
||||
|
||||
AutoTypeEmitter.prototype.setDelay = function(delay) {
|
||||
AutoTypeEmitter.prototype.setDelay = function (delay) {
|
||||
this.delay = delay || 0;
|
||||
this.callback('Not implemented');
|
||||
};
|
||||
|
||||
AutoTypeEmitter.prototype.modStr = function() {
|
||||
AutoTypeEmitter.prototype.modStr = function () {
|
||||
return Object.keys(this.mod).join('');
|
||||
};
|
||||
|
||||
AutoTypeEmitter.prototype.runScript = function(script) {
|
||||
AutoTypeEmitter.prototype.runScript = function (script) {
|
||||
Launcher.spawn({
|
||||
cmd: AutoTypeNativeHelper.getHelperPath(),
|
||||
data: script,
|
||||
|
|
|
@ -23,9 +23,9 @@ const OtherAppsScript =
|
|||
' end tell\n' +
|
||||
'end tell';
|
||||
|
||||
const AutoTypeHelper = function() {};
|
||||
const AutoTypeHelper = function () {};
|
||||
|
||||
AutoTypeHelper.prototype.getActiveWindowInfo = function(callback) {
|
||||
AutoTypeHelper.prototype.getActiveWindowInfo = function (callback) {
|
||||
AutoTypeHelper.exec(ForeMostAppScript, (err, out) => {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
|
@ -81,7 +81,7 @@ AutoTypeHelper.prototype.getActiveWindowInfo = function(callback) {
|
|||
});
|
||||
};
|
||||
|
||||
AutoTypeHelper.exec = function(script, callback) {
|
||||
AutoTypeHelper.exec = function (script, callback) {
|
||||
Launcher.spawn({
|
||||
cmd: 'osascript',
|
||||
args: ['-e', script],
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { Launcher } from 'comp/launcher';
|
||||
|
||||
const AutoTypeHelper = function() {};
|
||||
const AutoTypeHelper = function () {};
|
||||
|
||||
AutoTypeHelper.prototype.getActiveWindowInfo = function(callback) {
|
||||
AutoTypeHelper.prototype.getActiveWindowInfo = function (callback) {
|
||||
Launcher.spawn({
|
||||
cmd: 'xdotool',
|
||||
args: ['getactivewindow', 'getwindowname', 'getactivewindow'],
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { AutoTypeNativeHelper } from 'auto-type/helper/auto-type-native-helper';
|
||||
import { Launcher } from 'comp/launcher';
|
||||
|
||||
const AutoTypeHelper = function() {};
|
||||
const AutoTypeHelper = function () {};
|
||||
|
||||
AutoTypeHelper.prototype.getActiveWindowInfo = function(callback) {
|
||||
AutoTypeHelper.prototype.getActiveWindowInfo = function (callback) {
|
||||
Launcher.spawn({
|
||||
cmd: AutoTypeNativeHelper.getHelperPath(),
|
||||
args: ['--window-info'],
|
||||
|
|
|
@ -26,11 +26,11 @@ const AutoType = {
|
|||
if (!this.enabled) {
|
||||
return;
|
||||
}
|
||||
Events.on('auto-type', e => this.handleEvent(e));
|
||||
Events.on('main-window-blur', e => this.mainWindowBlur(e));
|
||||
Events.on('main-window-focus', e => this.mainWindowFocus(e));
|
||||
Events.on('main-window-will-close', e => this.mainWindowWillClose(e));
|
||||
Events.on('closed-open-view', e => this.processPendingEvent(e));
|
||||
Events.on('auto-type', (e) => this.handleEvent(e));
|
||||
Events.on('main-window-blur', (e) => this.mainWindowBlur(e));
|
||||
Events.on('main-window-focus', (e) => this.mainWindowFocus(e));
|
||||
Events.on('main-window-will-close', (e) => this.mainWindowWillClose(e));
|
||||
Events.on('closed-open-view', (e) => this.processPendingEvent(e));
|
||||
},
|
||||
|
||||
handleEvent(e) {
|
||||
|
@ -62,7 +62,7 @@ const AutoType = {
|
|||
},
|
||||
|
||||
runAndHandleResult(result, windowId) {
|
||||
this.run(result, windowId, err => {
|
||||
this.run(result, windowId, (err) => {
|
||||
if (err) {
|
||||
Alerts.error({
|
||||
header: Locale.autoTypeError,
|
||||
|
@ -86,7 +86,7 @@ const AutoType = {
|
|||
const parser = new AutoTypeParser(sequence);
|
||||
const runner = parser.parse();
|
||||
logger.debug('Parsed', this.printOps(runner.ops));
|
||||
runner.resolve(result.entry, context, err => {
|
||||
runner.resolve(result.entry, context, (err) => {
|
||||
if (err) {
|
||||
this.running = false;
|
||||
logger.error('Resolve error', err);
|
||||
|
@ -103,7 +103,7 @@ const AutoType = {
|
|||
}
|
||||
logger.debug('Obfuscated');
|
||||
}
|
||||
runner.run(err => {
|
||||
runner.run((err) => {
|
||||
this.running = false;
|
||||
if (err) {
|
||||
logger.error('Run error', err);
|
||||
|
@ -237,7 +237,7 @@ const AutoType = {
|
|||
this.focusMainWindow();
|
||||
evt.filter.ignoreWindowInfo = true;
|
||||
this.selectEntryView = new AutoTypeSelectView({ filter: evt.filter });
|
||||
this.selectEntryView.on('result', result => {
|
||||
this.selectEntryView.on('result', (result) => {
|
||||
logger.debug('Entry selected', result);
|
||||
this.selectEntryView.off('result');
|
||||
this.selectEntryView.remove();
|
||||
|
|
|
@ -5,19 +5,19 @@ class FileCollection extends Collection {
|
|||
static model = Model;
|
||||
|
||||
hasOpenFiles() {
|
||||
return this.some(file => file.active);
|
||||
return this.some((file) => file.active);
|
||||
}
|
||||
|
||||
hasUnsavedFiles() {
|
||||
return this.some(file => file.modified);
|
||||
return this.some((file) => file.modified);
|
||||
}
|
||||
|
||||
hasDirtyFiles() {
|
||||
return this.some(file => file.dirty);
|
||||
return this.some((file) => file.dirty);
|
||||
}
|
||||
|
||||
getByName(name) {
|
||||
return this.find(file => file.name.toLowerCase() === name.toLowerCase());
|
||||
return this.find((file) => file.name.toLowerCase() === name.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ class FileInfoCollection extends Collection {
|
|||
static model = FileInfoModel;
|
||||
|
||||
load() {
|
||||
return SettingsStore.load('file-info').then(data => {
|
||||
return SettingsStore.load('file-info').then((data) => {
|
||||
if (data) {
|
||||
for (const item of data) {
|
||||
this.push(new FileInfoModel(item));
|
||||
|
@ -20,7 +20,7 @@ class FileInfoCollection extends Collection {
|
|||
}
|
||||
|
||||
getMatch(storage, name, path) {
|
||||
return this.find(fi => {
|
||||
return this.find((fi) => {
|
||||
return (
|
||||
(fi.storage || '') === (storage || '') &&
|
||||
(fi.name || '') === (name || '') &&
|
||||
|
@ -30,7 +30,7 @@ class FileInfoCollection extends Collection {
|
|||
}
|
||||
|
||||
getByName(name) {
|
||||
return this.find(file => file.name.toLowerCase() === name.toLowerCase());
|
||||
return this.find((file) => file.name.toLowerCase() === name.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ const AppRightsChecker = {
|
|||
if (!Launcher.getAppPath().startsWith(this.AppPath)) {
|
||||
return;
|
||||
}
|
||||
this.needRunInstaller(needRun => {
|
||||
this.needRunInstaller((needRun) => {
|
||||
if (needRun) {
|
||||
this.showAlert();
|
||||
this.runInstaller();
|
||||
|
@ -26,7 +26,7 @@ const AppRightsChecker = {
|
|||
},
|
||||
|
||||
needRunInstaller(callback) {
|
||||
Launcher.statFile(this.AppPath, stat => {
|
||||
Launcher.statFile(this.AppPath, (stat) => {
|
||||
const folderIsRoot = stat && stat.uid === 0;
|
||||
callback(!folderIsRoot);
|
||||
});
|
||||
|
@ -46,7 +46,7 @@ const AppRightsChecker = {
|
|||
{ result: 'skip', title: Locale.alertDoNotAsk, error: true },
|
||||
Alerts.buttons.ok
|
||||
],
|
||||
success: result => {
|
||||
success: (result) => {
|
||||
if (result === 'skip') {
|
||||
this.dontAskAnymore();
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ const AppRightsChecker = {
|
|||
Launcher.spawn({
|
||||
cmd: this.AppPath + '/Contents/Installer/KeeWeb Installer.app/Contents/MacOS/applet',
|
||||
complete: () => {
|
||||
this.needRunInstaller(needRun => {
|
||||
this.needRunInstaller((needRun) => {
|
||||
if (this.alert && !needRun) {
|
||||
this.alert.closeWithResult('cancel');
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ const AppRightsChecker = {
|
|||
},
|
||||
|
||||
dontAskAnymore() {
|
||||
this.needRunInstaller(needRun => {
|
||||
this.needRunInstaller((needRun) => {
|
||||
if (needRun) {
|
||||
AppSettingsModel.skipFolderRightsWarning = true;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ const ChalRespCalculator = {
|
|||
if (!params) {
|
||||
return null;
|
||||
}
|
||||
return challenge => {
|
||||
return (challenge) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
challenge = Buffer.from(challenge);
|
||||
const hexChallenge = challenge.toString('hex');
|
||||
|
@ -60,7 +60,7 @@ const ChalRespCalculator = {
|
|||
if (err) {
|
||||
if (err.noKey) {
|
||||
logger.info('YubiKey ChalResp: no key');
|
||||
this._showNoKeyAlert(params.serial, err => {
|
||||
this._showNoKeyAlert(params.serial, (err) => {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ const ChalRespCalculator = {
|
|||
return;
|
||||
} else if (err.touchRequested) {
|
||||
logger.info('YubiKey ChalResp: touch requested');
|
||||
touchAlert = this._showTouchAlert(params.serial, err => {
|
||||
touchAlert = this._showTouchAlert(params.serial, (err) => {
|
||||
touchAlert = null;
|
||||
userCanceled = true;
|
||||
|
||||
|
@ -114,7 +114,7 @@ const ChalRespCalculator = {
|
|||
logger.error('YubiKey list error', err);
|
||||
return;
|
||||
}
|
||||
const isAttached = list.some(yk => yk.serial === serial);
|
||||
const isAttached = list.some((yk) => yk.serial === serial);
|
||||
logger.info(isAttached ? 'YubiKey found' : 'YubiKey not found');
|
||||
if (isAttached) {
|
||||
Events.off('usb-devices-changed', onUsbDevicesChanged);
|
||||
|
|
|
@ -3,19 +3,19 @@ import { UrlFormat } from 'util/formatting/url-format';
|
|||
|
||||
const ChooserAppKey = 'qp7ctun6qt5n9d6';
|
||||
|
||||
const DropboxChooser = function(callback) {
|
||||
const DropboxChooser = function (callback) {
|
||||
this.cb = callback;
|
||||
this.onMessage = this.onMessage.bind(this);
|
||||
};
|
||||
|
||||
DropboxChooser.prototype.callback = function(err, res) {
|
||||
DropboxChooser.prototype.callback = function (err, res) {
|
||||
if (this.cb) {
|
||||
this.cb(err, res);
|
||||
}
|
||||
this.cb = null;
|
||||
};
|
||||
|
||||
DropboxChooser.prototype.choose = function() {
|
||||
DropboxChooser.prototype.choose = function () {
|
||||
const windowFeatures = 'width=640,height=552,left=357,top=100,resizable=yes,location=yes';
|
||||
const url = this.buildUrl();
|
||||
this.popup = window.open(url, 'dropbox', windowFeatures);
|
||||
|
@ -26,7 +26,7 @@ DropboxChooser.prototype.choose = function() {
|
|||
this.closeInt = setInterval(this.checkClose.bind(this), 200);
|
||||
};
|
||||
|
||||
DropboxChooser.prototype.buildUrl = function() {
|
||||
DropboxChooser.prototype.buildUrl = function () {
|
||||
return UrlFormat.makeUrl('https://www.dropbox.com/chooser', {
|
||||
origin: window.location.protocol + '//' + window.location.host,
|
||||
'app_key': AppSettingsModel.dropboxAppKey || ChooserAppKey,
|
||||
|
@ -40,7 +40,7 @@ DropboxChooser.prototype.buildUrl = function() {
|
|||
});
|
||||
};
|
||||
|
||||
DropboxChooser.prototype.onMessage = function(e) {
|
||||
DropboxChooser.prototype.onMessage = function (e) {
|
||||
if (e.source !== this.popup || e.origin !== 'https://www.dropbox.com') {
|
||||
return;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ DropboxChooser.prototype.onMessage = function(e) {
|
|||
}
|
||||
};
|
||||
|
||||
DropboxChooser.prototype.checkClose = function() {
|
||||
DropboxChooser.prototype.checkClose = function () {
|
||||
if (this.popup.closed) {
|
||||
clearInterval(this.closeInt);
|
||||
window.removeEventListener('message', this.onMessage);
|
||||
|
@ -79,7 +79,7 @@ DropboxChooser.prototype.checkClose = function() {
|
|||
}
|
||||
};
|
||||
|
||||
DropboxChooser.prototype.success = function(params) {
|
||||
DropboxChooser.prototype.success = function (params) {
|
||||
if (!params || !params[0] || !params[0].link || params[0].is_dir) {
|
||||
return this.callback('bad result');
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ DropboxChooser.prototype.success = function(params) {
|
|||
this.readFile(this.result.link);
|
||||
};
|
||||
|
||||
DropboxChooser.prototype.readFile = function(url) {
|
||||
DropboxChooser.prototype.readFile = function (url) {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.addEventListener('load', () => {
|
||||
this.callback(null, { name: this.result.name, data: xhr.response });
|
||||
|
|
|
@ -67,16 +67,16 @@ const GeneratorPresets = {
|
|||
|
||||
get all() {
|
||||
let presets = this.builtIn;
|
||||
presets.forEach(preset => {
|
||||
presets.forEach((preset) => {
|
||||
preset.builtIn = true;
|
||||
});
|
||||
const setting = AppSettingsModel.generatorPresets;
|
||||
if (setting) {
|
||||
if (setting.user) {
|
||||
presets = presets.concat(setting.user.map(item => ({ ...item })));
|
||||
presets = presets.concat(setting.user.map((item) => ({ ...item })));
|
||||
}
|
||||
let hasDefault = false;
|
||||
presets.forEach(preset => {
|
||||
presets.forEach((preset) => {
|
||||
if (setting.disabled && setting.disabled[preset.name]) {
|
||||
preset.disabled = true;
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ const GeneratorPresets = {
|
|||
},
|
||||
|
||||
get enabled() {
|
||||
const allPresets = this.all.filter(preset => !preset.disabled);
|
||||