var => let

pull/542/head
antelle 2017-01-31 07:50:28 +01:00
parent 4ed8da4d2f
commit a77f61cc5d
148 changed files with 1748 additions and 1725 deletions

View File

@ -12,7 +12,9 @@
"no-debugger": "error",
"prefer-arrow-callback": "error",
"object-property-newline": "off",
"no-useless-escape": "off"
"no-useless-escape": "off",
"no-var": "error",
"prefer-const": "error"
},
"globals": {
"_": true,

View File

@ -2,23 +2,23 @@
/* eslint-env node */
var fs = require('fs'),
path = require('path');
const fs = require('fs');
const path = require('path');
var StringReplacePlugin = require('string-replace-webpack-plugin');
var StatsPlugin = require('stats-webpack-plugin');
const StringReplacePlugin = require('string-replace-webpack-plugin');
const StatsPlugin = require('stats-webpack-plugin');
module.exports = function(grunt) {
require('time-grunt')(grunt);
require('load-grunt-tasks')(grunt);
grunt.loadTasks('grunt/tasks');
var webpack = require('webpack');
var pkg = require('./package.json');
var dt = new Date().toISOString().replace(/T.*/, '');
var minElectronVersionForUpdate = '1.0.1';
var zipCommentPlaceholder = 'zip_comment_placeholder_that_will_be_replaced_with_hash';
var electronVersion = pkg.devDependencies['electron'].replace(/^\D/, '');
const webpack = require('webpack');
const pkg = require('./package.json');
const dt = new Date().toISOString().replace(/T.*/, '');
const minElectronVersionForUpdate = '1.0.1';
let zipCommentPlaceholder = 'zip_comment_placeholder_that_will_be_replaced_with_hash';
const electronVersion = pkg.devDependencies['electron'].replace(/^\D/, '');
while (zipCommentPlaceholder.length < 512) {
zipCommentPlaceholder += '.';
@ -26,20 +26,20 @@ module.exports = function(grunt) {
function replaceFont(css) {
css.walkAtRules('font-face', rule => {
var fontFamily = rule.nodes.filter(n => n.prop === 'font-family')[0];
const fontFamily = rule.nodes.filter(n => n.prop === 'font-family')[0];
if (!fontFamily) {
throw 'Bad font rule: ' + rule.toString();
}
var value = fontFamily.value.replace(/["']/g, '');
var fontFiles = {
const value = fontFamily.value.replace(/["']/g, '');
const fontFiles = {
FontAwesome: 'fontawesome-webfont.woff'
};
var fontFile = fontFiles[value];
const fontFile = fontFiles[value];
if (!fontFile) {
throw 'Unsupported font ' + value + ': ' + rule.toString();
}
var data = fs.readFileSync('tmp/fonts/' + fontFile, 'base64');
var src = 'url(data:application/font-woff;charset=utf-8;base64,{data}) format(\'woff\')'
const data = fs.readFileSync('tmp/fonts/' + fontFile, 'base64');
const src = 'url(data:application/font-woff;charset=utf-8;base64,{data}) format(\'woff\')'
.replace('{data}', data);
// var src = 'url(\'../fonts/fontawesome-webfont.woff\') format(\'woff\')';
rule.nodes = rule.nodes.filter(n => n.prop !== 'src');
@ -47,7 +47,7 @@ module.exports = function(grunt) {
});
}
var webpackConfig = {
const webpackConfig = {
entry: {
app: 'app',
vendor: ['jquery', 'underscore', 'backbone', 'kdbxweb', 'baron', 'dropbox', 'pikaday', 'filesaver', 'qrcode', 'argon2']

View File

@ -1,18 +1,18 @@
'use strict';
var AppModel = require('./models/app-model'),
AppView = require('./views/app-view'),
KeyHandler = require('./comp/key-handler'),
IdleTracker = require('./comp/idle-tracker'),
PopupNotifier = require('./comp/popup-notifier'),
SingleInstanceChecker = require('./comp/single-instance-checker'),
Alerts = require('./comp/alerts'),
Updater = require('./comp/updater'),
AuthReceiver = require('./comp/auth-receiver'),
ExportApi = require('./comp/export-api'),
SettingsManager = require('./comp/settings-manager'),
KdbxwebInit = require('./util/kdbxweb-init'),
Locale = require('./util/locale');
const AppModel = require('./models/app-model');
const AppView = require('./views/app-view');
const KeyHandler = require('./comp/key-handler');
const IdleTracker = require('./comp/idle-tracker');
const PopupNotifier = require('./comp/popup-notifier');
const SingleInstanceChecker = require('./comp/single-instance-checker');
const Alerts = require('./comp/alerts');
const Updater = require('./comp/updater');
const AuthReceiver = require('./comp/auth-receiver');
const ExportApi = require('./comp/export-api');
const SettingsManager = require('./comp/settings-manager');
const KdbxwebInit = require('./util/kdbxweb-init');
const Locale = require('./util/locale');
$(() => {
if (isPopup()) {
@ -21,9 +21,9 @@ $(() => {
loadMixins();
initModules();
var appModel = new AppModel();
const appModel = new AppModel();
SettingsManager.setBySettings(appModel.settings);
var configParam = getConfigParam();
const configParam = getConfigParam();
if (configParam) {
appModel.loadConfig(configParam, err => {
SettingsManager.setBySettings(appModel.settings);
@ -64,9 +64,9 @@ $(() => {
}
function showApp() {
let skipHttpsWarning = localStorage.skipHttpsWarning || appModel.settings.get('skipHttpsWarning');
let protocolIsInsecure = ['https:', 'file:', 'app:'].indexOf(location.protocol) < 0;
let hostIsInsecure = location.hostname !== 'localhost';
const skipHttpsWarning = localStorage.skipHttpsWarning || appModel.settings.get('skipHttpsWarning');
const protocolIsInsecure = ['https:', 'file:', 'app:'].indexOf(location.protocol) < 0;
const hostIsInsecure = location.hostname !== 'localhost';
if (protocolIsInsecure && hostIsInsecure && !skipHttpsWarning) {
Alerts.error({ header: Locale.appSecWarn, icon: 'user-secret', esc: false, enter: false, click: false,
body: Locale.appSecWarnBody1 + '<br/><br/>' + Locale.appSecWarnBody2,
@ -88,11 +88,11 @@ $(() => {
}
function getConfigParam() {
let metaConfig = document.head.querySelector('meta[name=kw-config]');
const metaConfig = document.head.querySelector('meta[name=kw-config]');
if (metaConfig && metaConfig.content && metaConfig.content[0] !== '(') {
return metaConfig.content;
}
var match = location.search.match(/[?&]config=([^&]+)/i);
const match = location.search.match(/[?&]config=([^&]+)/i);
if (match && match[1]) {
return match[1];
}

View File

@ -1,13 +1,13 @@
'use strict';
var Launcher = require('../comp/launcher');
const Launcher = require('../comp/launcher');
var AutoTypeEmitterFactory = {
const AutoTypeEmitterFactory = {
create: function(callback) {
if (!Launcher) {
return null;
}
var AutoTypeEmitter = require('./emitter/auto-type-emitter-' + Launcher.platform());
const AutoTypeEmitter = require('./emitter/auto-type-emitter-' + Launcher.platform());
return new AutoTypeEmitter(callback);
}
};

View File

@ -2,9 +2,9 @@
const EntryCollection = require('../collections/entry-collection');
let urlPartsRegex = /^(\w+:\/\/)?(?:www\.)?([^\/]+)\/?(.*)/;
const urlPartsRegex = /^(\w+:\/\/)?(?:www\.)?([^\/]+)\/?(.*)/;
let AutoTypeFilter = function(windowInfo, appModel) {
const AutoTypeFilter = function(windowInfo, appModel) {
this.title = windowInfo.title;
this.url = windowInfo.url;
this.text = '';
@ -13,7 +13,7 @@ let AutoTypeFilter = function(windowInfo, appModel) {
};
AutoTypeFilter.prototype.getEntries = function() {
let filter = {
const filter = {
text: this.text,
autoType: true
};
@ -47,7 +47,7 @@ AutoTypeFilter.prototype.getEntryRank = function(entry) {
rank += this.getStringRank(entry.title.toLowerCase(), this.titleLower);
}
if (this.urlParts && entry.url) {
let entryUrlParts = urlPartsRegex.exec(entry.url.toLowerCase());
const entryUrlParts = urlPartsRegex.exec(entry.url.toLowerCase());
if (entryUrlParts) {
// domain
if (entryUrlParts[2] === this.urlParts[2]) {

View File

@ -1,13 +1,13 @@
'use strict';
var Launcher = require('../comp/launcher');
const Launcher = require('../comp/launcher');
var AutoTypeHelperFactory = {
const AutoTypeHelperFactory = {
create: function() {
if (!Launcher) {
return null;
}
var AutoTypeHelper = require('./helper/auto-type-helper-' + Launcher.platform());
const AutoTypeHelper = require('./helper/auto-type-helper-' + Launcher.platform());
return new AutoTypeHelper();
}
};

View File

@ -1,16 +1,16 @@
'use strict';
var Logger = require('../util/logger');
const Logger = require('../util/logger');
var logger = new Logger('auto-type-obfuscator');
const logger = new Logger('auto-type-obfuscator');
logger.setLevel(localStorage.autoTypeDebug ? Logger.Level.All : Logger.Level.Warn);
var MaxFakeOps = 30;
var MaxSteps = 1000;
var MaxCopy = 2;
var FakeCharAlphabet = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz123456789O0oIl';
const MaxFakeOps = 30;
const MaxSteps = 1000;
const MaxCopy = 2;
const FakeCharAlphabet = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz123456789O0oIl';
var AutoTypeObfuscator = function(chars) {
const AutoTypeObfuscator = function(chars) {
this.chars = chars;
this.inputChars = [];
this.inputCursor = 0;
@ -27,7 +27,7 @@ AutoTypeObfuscator.prototype.obfuscate = function() {
throw 'Obfuscate failed';
}
}
for (var i = 0; i < this.chars.length; i++) {
for (let i = 0; i < this.chars.length; i++) {
this.chars[i] = null;
this.inputChars[i] = null;
}
@ -40,7 +40,7 @@ AutoTypeObfuscator.prototype.finished = function() {
};
AutoTypeObfuscator.prototype.step = function() {
var isFake = this.stepCount < MaxFakeOps && Math.random() > this.stepCount / MaxFakeOps;
const isFake = this.stepCount < MaxFakeOps && Math.random() > this.stepCount / MaxFakeOps;
if (isFake) {
this.stepFake();
} else {
@ -52,21 +52,21 @@ AutoTypeObfuscator.prototype.step = function() {
};
AutoTypeObfuscator.prototype.stepFake = function() {
var pos = Math.floor(Math.random() * (this.inputChars.length + 1));
var ch = FakeCharAlphabet[Math.floor(Math.random() * FakeCharAlphabet.length)];
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);
this.moveToPos(pos);
var insert = this.inputChars.length === 0 || Math.random() > 0.3;
const insert = this.inputChars.length === 0 || Math.random() > 0.3;
if (insert) {
this.inputChar(ch);
} else {
var moveLeft = Math.random() > 0.5;
var maxMove = moveLeft ? pos : this.inputChars.length - pos;
let moveLeft = Math.random() > 0.5;
let maxMove = moveLeft ? pos : this.inputChars.length - pos;
if (maxMove === 0) {
moveLeft = !moveLeft;
maxMove = moveLeft ? pos : this.inputChars.length - pos;
}
var moveCount = Math.max(Math.floor(Math.pow(Math.random(), 3) * maxMove), 1);
const moveCount = Math.max(Math.floor(Math.pow(Math.random(), 3) * maxMove), 1);
if (moveCount <= 1 && Math.random() > 0.5) {
this.deleteText(moveLeft);
} else {
@ -81,14 +81,14 @@ AutoTypeObfuscator.prototype.stepFake = function() {
};
AutoTypeObfuscator.prototype.stepReal = function() {
var possibleActions = [];
var inputRealPositions = [];
var i;
const possibleActions = [];
const inputRealPositions = [];
let i;
for (i = 0; i < this.chars.length; i++) {
inputRealPositions.push(-1);
}
for (i = 0; i < this.inputChars.length; i++) {
var ix = this.inputChars[i].ix;
const ix = this.inputChars[i].ix;
if (ix === undefined) {
possibleActions.push({ del: true, pos: i });
} else {
@ -97,8 +97,9 @@ AutoTypeObfuscator.prototype.stepReal = function() {
}
for (i = 0; i < this.chars.length; i++) {
if (inputRealPositions[i] < 0) {
var from = 0, to = this.inputChars.length;
for (var j = 0; j < this.chars.length; j++) {
let from = 0,
to = this.inputChars.length;
for (let j = 0; j < this.chars.length; j++) {
if (j < i && inputRealPositions[j] >= 0) {
from = inputRealPositions[j] + 1;
}
@ -110,13 +111,13 @@ AutoTypeObfuscator.prototype.stepReal = function() {
possibleActions.push({ ins: true, ch: this.chars[i], ix: i, from: from, to: to });
}
}
var action = possibleActions[Math.floor(Math.random() * possibleActions.length)];
const action = possibleActions[Math.floor(Math.random() * possibleActions.length)];
logger.info('step.real', inputRealPositions, action);
if (action.del) {
this.moveToPos(action.pos + 1);
this.deleteText(true);
} else {
var insPos = action.from + Math.floor(Math.random() * (action.to - action.from));
const insPos = action.from + Math.floor(Math.random() * (action.to - action.from));
this.moveToPos(insPos);
if (this.copyCount < MaxCopy && action.ch !== '\n' && Math.random() > 0.5) {
this.copyCount++;
@ -170,8 +171,8 @@ AutoTypeObfuscator.prototype.copyPaste = function(ch) {
AutoTypeObfuscator.prototype.selectText = function(backward, count) {
logger.debug('selectText', backward ? 'left' : 'right', count);
var ops = [];
for (var i = 0; i < count; i++) {
const ops = [];
for (let i = 0; i < count; i++) {
ops.push({ type: 'key', value: backward ? 'left' : 'right' });
}
if (ops.length === 1) {

View File

@ -1,8 +1,8 @@
'use strict';
var AutoTypeRunner = require('./auto-type-runner');
const AutoTypeRunner = require('./auto-type-runner');
var AutoTypeParser = function(sequence) {
const AutoTypeParser = function(sequence) {
this.sequence = sequence;
this.ix = 0;
this.states = [];
@ -11,10 +11,10 @@ var AutoTypeParser = function(sequence) {
AutoTypeParser.opSepRegex = /[\s:=]+/;
AutoTypeParser.prototype.parse = function() {
var len = this.sequence.length;
const len = this.sequence.length;
this.pushState();
while (this.ix < len) {
var ch = this.sequence[this.ix];
const ch = this.sequence[this.ix];
switch (ch) {
case '{':
this.readOp();
@ -58,7 +58,7 @@ AutoTypeParser.prototype.popState = function() {
if (this.states.length <= 1) {
throw 'Unexpected ")" at index ' + this.ix;
}
var state = this.states.shift();
const state = this.states.shift();
this.addState(state);
};
@ -67,21 +67,21 @@ AutoTypeParser.prototype.state = function() {
};
AutoTypeParser.prototype.readOp = function() {
var toIx = this.sequence.indexOf('}', this.ix + 2);
const toIx = this.sequence.indexOf('}', this.ix + 2);
if (toIx < 0) {
throw 'Mismatched "{" at index ' + this.ix;
}
var contents = this.sequence.substring(this.ix + 1, toIx);
const contents = this.sequence.substring(this.ix + 1, toIx);
this.ix = toIx + 1;
if (contents.length === 1) {
this.addChar(contents);
return;
}
var parts = contents.split(AutoTypeParser.opSepRegex, 2);
const parts = contents.split(AutoTypeParser.opSepRegex, 2);
if (parts.length > 1 && parts[0].length && parts[1].length) {
var op = parts[0];
var sep = contents.substr(op.length, 1);
var arg = parts[1];
const op = parts[0];
const sep = contents.substr(op.length, 1);
const arg = parts[1];
this.addOp(op, sep, arg);
} else {
this.addOp(contents);
@ -89,7 +89,7 @@ AutoTypeParser.prototype.readOp = function() {
};
AutoTypeParser.prototype.readModifier = function(modifier) {
var state = this.state();
const state = this.state();
if (!state.modifiers) {
state.modifiers = {};
}
@ -101,8 +101,8 @@ AutoTypeParser.prototype.readModifier = function(modifier) {
};
AutoTypeParser.prototype.resetModifiers = function() {
var state = this.state();
var modifiers = state.modifiers;
const state = this.state();
const modifiers = state.modifiers;
state.modifiers = null;
return modifiers;
};

View File

@ -1,14 +1,14 @@
'use strict';
var AutoTypeObfuscator = require('./auto-type-obfuscator'),
AutoTypeEmitterFactory = require('./auto-type-emitter-factory'),
Format = require('../util/format'),
Logger = require('../util/logger');
const AutoTypeObfuscator = require('./auto-type-obfuscator');
const AutoTypeEmitterFactory = require('./auto-type-emitter-factory');
const Format = require('../util/format');
const Logger = require('../util/logger');
var emitterLogger = new Logger('auto-type-emitter');
const emitterLogger = new Logger('auto-type-emitter');
emitterLogger.setLevel(localStorage.autoTypeDebug ? Logger.Level.All : Logger.Level.Warn);
var AutoTypeRunner = function(ops) {
const AutoTypeRunner = function(ops) {
this.ops = ops;
this.pendingResolvesCount = 0;
this.entry = null;
@ -68,8 +68,8 @@ AutoTypeRunner.prototype.resolve = function(entry, callback) {
};
AutoTypeRunner.prototype.resolveOps = function(ops) {
for (var i = 0, len = ops.length; i < len; i++) {
var op = ops[i];
for (let i = 0, len = ops.length; i < len; i++) {
const op = ops[i];
if (op.type === 'group') {
this.resolveOps(op.value);
} else {
@ -87,22 +87,24 @@ AutoTypeRunner.prototype.resolveOp = function(op) {
if (op.value.length === 1 && op.sep === ' ') {
// {x 3}
op.type = 'text';
var ch = op.value, text = ch, len = +op.arg;
const ch = op.value;
let text = ch;
const len = +op.arg;
while (text.length < len) {
text += ch;
}
op.value = text;
return;
}
var lowerValue = op.value.toLowerCase();
var key = AutoTypeRunner.Keys[lowerValue];
const lowerValue = op.value.toLowerCase();
const key = AutoTypeRunner.Keys[lowerValue];
if (key) {
if (op.sep === ' ' && +op.arg > 0) {
// {TAB 3}
op.type = 'group';
op.value = [];
var count = +op.arg;
for (var i = 0; i < count; i++) {
const count = +op.arg;
for (let i = 0; i < count; i++) {
op.value.push({type: 'key', value: key});
}
} else {
@ -112,7 +114,7 @@ AutoTypeRunner.prototype.resolveOp = function(op) {
}
return;
}
var substitution = AutoTypeRunner.Substitutions[lowerValue];
const substitution = AutoTypeRunner.Substitutions[lowerValue];
if (substitution) {
// {title}
op.type = 'text';
@ -170,13 +172,13 @@ AutoTypeRunner.prototype.getEntryFieldKeys = function(field, op) {
if (!field || !this.entry) {
return '';
}
var value = this.entry.getFieldValue(field);
const value = this.entry.getFieldValue(field);
if (!value) {
return '';
}
if (value.isProtected) {
op.type = 'group';
var ops = [];
const ops = [];
value.forEachChar(ch => {
if (ch === 10 || ch === 13) {
ops.push({type: 'key', value: 'enter'});
@ -186,12 +188,12 @@ AutoTypeRunner.prototype.getEntryFieldKeys = function(field, op) {
});
return ops;
} else {
var parts = value.split(/[\r\n]/g);
const parts = value.split(/[\r\n]/g);
if (parts.length === 1) {
return value;
}
op.type = 'group';
var partsOps = [];
const partsOps = [];
parts.forEach(part => {
if (partsOps.length) {
partsOps.push({type: 'key', value: 'enter'});
@ -265,7 +267,7 @@ AutoTypeRunner.prototype.getOtp = function(op) {
};
AutoTypeRunner.prototype.pendingResolved = function(op, value, error) {
var wasPending = op.value === AutoTypeRunner.PendingResolve;
const wasPending = op.value === AutoTypeRunner.PendingResolve;
if (value) {
op.value = value;
}
@ -284,15 +286,15 @@ AutoTypeRunner.prototype.obfuscate = function() {
};
AutoTypeRunner.prototype.obfuscateOps = function(ops) {
for (var i = 0, len = ops.length; i < len; i++) {
var op = ops[i];
for (let i = 0, len = ops.length; i < len; i++) {
const op = ops[i];
if (op.mod) {
continue;
}
if (op.type === 'text') {
this.obfuscateOp(op);
} else if (op.type === 'group') {
var 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 {
@ -303,7 +305,7 @@ AutoTypeRunner.prototype.obfuscateOps = function(ops) {
};
AutoTypeRunner.prototype.obfuscateOp = function(op) {
var letters = [];
let letters = [];
if (op.type === 'text') {
if (!op.value || op.value.length <= 1) {
return;
@ -315,7 +317,7 @@ AutoTypeRunner.prototype.obfuscateOp = function(op) {
if (letters.length <= 1) {
return;
}
var obfuscator = new AutoTypeObfuscator(letters);
const obfuscator = new AutoTypeObfuscator(letters);
op.value = obfuscator.obfuscate();
op.type = 'group';
};
@ -346,7 +348,7 @@ AutoTypeRunner.prototype.emitNext = function(err) {
}
this.resetEmitterMod(this.emitterState.mod);
if (this.emitterState.opIx >= this.emitterState.ops.length) {
var state = this.emitterState.stack.pop();
const state = this.emitterState.stack.pop();
if (state) {
_.extend(this.emitterState, { ops: state.ops, opIx: state.opIx, mod: state.mod });
this.emitNext();
@ -358,7 +360,7 @@ AutoTypeRunner.prototype.emitNext = function(err) {
}
return;
}
var op = this.emitterState.ops[this.emitterState.opIx];
const op = this.emitterState.ops[this.emitterState.opIx];
if (op.type === 'group') {
if (op.mod) {
this.setEmitterMod(op.mod);
@ -392,7 +394,7 @@ AutoTypeRunner.prototype.emitNext = function(err) {
this.emitter.key(op.value);
break;
case 'cmd':
var method = this.emitter[op.value];
const method = this.emitter[op.value];
if (!method) {
throw 'Bad cmd: ' + op.value;
}

View File

@ -4,7 +4,7 @@ const Launcher = require('../../comp/launcher');
const AutoTypeNativeHelper = require('../helper/auto-type-native-helper');
// http://eastmanreference.com/complete-list-of-applescript-key-codes/
var KeyMap = {
const KeyMap = {
tab: 48, enter: 36, space: 49,
up: 126, down: 125, left: 123, right: 124, home: 115, end: 119, pgup: 116, pgdn: 121,
ins: 114, del: 117, bs: 51, esc: 53,
@ -16,14 +16,14 @@ var KeyMap = {
n5: 87, n6: 88, n7: 89, n8: 91, n9: 92
};
var ModMap = {
const ModMap = {
'^': '@',
'+': '+',
'%': '%',
'^^': '^'
};
var AutoTypeEmitter = function(callback) {
const AutoTypeEmitter = function(callback) {
this.callback = callback;
this.mod = {};
this.pendingScript = [];
@ -65,7 +65,7 @@ AutoTypeEmitter.prototype.wait = function(time) {
AutoTypeEmitter.prototype.waitComplete = function() {
if (this.pendingScript.length) {
var script = this.pendingScript.join('\n');
const script = this.pendingScript.join('\n');
this.pendingScript.length = 0;
this.runScript(script);
} else {

View File

@ -23,7 +23,7 @@ const ModMap = {
'^^': 'ctrl'
};
var AutoTypeEmitter = function(callback) {
const AutoTypeEmitter = function(callback) {
this.callback = callback;
this.mod = {};
this.pendingScript = [];
@ -77,7 +77,7 @@ AutoTypeEmitter.prototype.wait = function(time) {
AutoTypeEmitter.prototype.waitComplete = function(callback) {
if (this.pendingScript.length) {
var script = this.pendingScript.join(' ');
const script = this.pendingScript.join(' ');
this.pendingScript.length = 0;
this.runScript(script, callback);
} else {
@ -86,7 +86,7 @@ AutoTypeEmitter.prototype.waitComplete = function(callback) {
};
AutoTypeEmitter.prototype.modString = function() {
var mod = '';
let mod = '';
Object.keys(this.mod).forEach(key => {
mod += key + '+';
});
@ -102,7 +102,7 @@ AutoTypeEmitter.prototype.runScript = function(script, callback) {
if (err && err.code === 'ENOENT') {
err = Locale.autoTypeErrorNotInstalled.replace('{}', 'xdotool');
}
let cb = callback || this.callback;
const cb = callback || this.callback;
cb(err, stdout, code);
}
});

View File

@ -1,10 +1,10 @@
'use strict';
var Launcher = require('../../comp/launcher'),
AutoTypeNativeHelper = require('../helper/auto-type-native-helper');
const Launcher = require('../../comp/launcher');
const AutoTypeNativeHelper = require('../helper/auto-type-native-helper');
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
var KeyMap = {
const KeyMap = {
tab: 0x09, enter: 0x0D, space: 0x20,
up: 0x26, down: 0x28, left: 0x25, right: 0x27, home: 0x24, end: 0x23, pgup: 0x21, pgdn: 0x22,
ins: 0x2D, del: 0x2E, bs: 0x08, esc: 0x1B,
@ -16,14 +16,14 @@ var KeyMap = {
n5: 0x35, n6: 0x36, n7: 0x37, n8: 0x38, n9: 0x39
};
var ModMap = {
const ModMap = {
'^': '^',
'+': '+',
'%': '%',
'^^': '^'
};
var AutoTypeEmitter = function(callback) {
const AutoTypeEmitter = function(callback) {
this.callback = callback;
this.mod = {};
this.pendingScript = [];
@ -67,7 +67,7 @@ AutoTypeEmitter.prototype.wait = function(time) {
AutoTypeEmitter.prototype.waitComplete = function() {
if (this.pendingScript.length) {
var script = this.pendingScript.join('\n');
const script = this.pendingScript.join('\n');
this.pendingScript.length = 0;
this.runScript(script);
} else {

View File

@ -1,15 +1,15 @@
'use strict';
var Launcher = require('../../comp/launcher');
const Launcher = require('../../comp/launcher');
var ForeMostAppScript = 'tell application "System Events" to set frontApp to name of first process whose frontmost is true';
var ChromeScript = 'tell application "{}" to set appUrl to URL of active tab of front window\n' +
const ForeMostAppScript = 'tell application "System Events" to set frontApp to name of first process whose frontmost is true';
const ChromeScript = 'tell application "{}" to set appUrl to URL of active tab of front window\n' +
'tell application "{}" to set appTitle to title of active tab of front window\n' +
'return appUrl & "\n" & appTitle';
var SafariScript = 'tell application "{}" to set appUrl to URL of front document\n' +
const SafariScript = 'tell application "{}" to set appUrl to URL of front document\n' +
'tell application "{}" to set appTitle to name of front document\n' +
'return appUrl & "\n" & appTitle';
var OtherAppsScript = 'tell application "System Events"\n' +
const OtherAppsScript = 'tell application "System Events"\n' +
' tell process "{}"\n' +
' tell (1st window whose value of attribute "AXMain" is true)\n' +
' set windowTitle to value of attribute "AXTitle"\n' +
@ -17,13 +17,13 @@ var OtherAppsScript = 'tell application "System Events"\n' +
' end tell\n' +
'end tell';
var AutoTypeHelper = function() {
const AutoTypeHelper = function() {
};
AutoTypeHelper.prototype.getActiveWindowTitle = function(callback) {
AutoTypeHelper.exec(ForeMostAppScript, (err, out) => {
if (err) { return callback(err); }
var appName = out.trim();
const appName = out.trim();
// getting urls and titles from Chrome or Safari:
// - will suit in 90% cases
// - does not require assistive access
@ -31,13 +31,13 @@ AutoTypeHelper.prototype.getActiveWindowTitle = function(callback) {
if (['Google Chrome', 'Chromium', 'Google Chrome Canary'].indexOf(appName) >= 0) {
AutoTypeHelper.exec(ChromeScript.replace(/\{}/g, appName), (err, out) => {
if (err) { return callback(err); }
var parts = out.split('\n');
const parts = out.split('\n');
return callback(null, parts[1].trim(), parts[0].trim());
});
} else if (['Safari', 'Webkit'].indexOf(appName) >= 0) {
AutoTypeHelper.exec(SafariScript.replace(/\{}/g, appName), (err, out) => {
if (err) { return callback(err); }
var parts = out.split('\n');
const parts = out.split('\n');
return callback(null, parts[1].trim(), parts[0].trim());
});
} else {

View File

@ -1,8 +1,8 @@
'use strict';
var Launcher = require('../../comp/launcher');
const Launcher = require('../../comp/launcher');
var AutoTypeHelper = function() {
const AutoTypeHelper = function() {
};
AutoTypeHelper.prototype.getActiveWindowTitle = function(callback) {

View File

@ -12,7 +12,7 @@ AutoTypeHelper.prototype.getActiveWindowTitle = function(callback) {
args: ['--window-info'],
complete: function(err, out) {
if (err) { return callback(err); }
var parts = out.split('\n');
const parts = out.split('\n');
return callback(null, (parts[0] || '').trim(),
parts[1] ? parts[1].trim() : undefined);
}

View File

@ -10,17 +10,18 @@ const AutoTypeNativeHelper = {
if (this._helperPath) {
return this._helperPath;
}
let ext = process.platform === 'win32' ? '.exe' : '';
let part = `helper/${process.platform}/KeeWebHelper${ext}`;
let possiblePaths = [
const ext = process.platform === 'win32' ? '.exe' : '';
const part = `helper/${process.platform}/KeeWebHelper${ext}`;
const possiblePaths = [
Launcher.getAppPath(part),
Launcher.getUserDataPath(part),
Launcher.getWorkDirPath(part)
];
let helperPath, helperCTime = -1;
let helperPath;
const helperCTime = -1;
possiblePaths.forEach(possiblePath => {
try {
let ctime = Launcher.statFile(possiblePath).ctime;
const ctime = Launcher.statFile(possiblePath).ctime;
if (ctime > helperCTime) {
helperPath = possiblePath;
}

View File

@ -1,20 +1,20 @@
'use strict';
var Backbone = require('backbone'),
AutoTypeParser = require('./auto-type-parser'),
AutoTypeFilter = require('./auto-type-filter'),
AutoTypeHelperFactory = require('./auto-type-helper-factory'),
Launcher = require('../comp/launcher'),
Alerts = require('../comp/alerts'),
AutoTypeSelectView = require('../views/auto-type/auto-type-select-view'),
Logger = require('../util/logger'),
Locale = require('../util/locale'),
Timeouts = require('../const/timeouts');
const Backbone = require('backbone');
const AutoTypeParser = require('./auto-type-parser');
const AutoTypeFilter = require('./auto-type-filter');
const AutoTypeHelperFactory = require('./auto-type-helper-factory');
const Launcher = require('../comp/launcher');
const Alerts = require('../comp/alerts');
const AutoTypeSelectView = require('../views/auto-type/auto-type-select-view');
const Logger = require('../util/logger');
const Locale = require('../util/locale');
const Timeouts = require('../const/timeouts');
var logger = new Logger('auto-type');
var clearTextAutoTypeLog = localStorage.autoTypeDebug;
const logger = new Logger('auto-type');
const clearTextAutoTypeLog = localStorage.autoTypeDebug;
var AutoType = {
const AutoType = {
helper: AutoTypeHelperFactory.create(),
enabled: !!Launcher,
selectEntryView: false,
@ -31,7 +31,7 @@ var AutoType = {
},
handleEvent(e) {
let entry = e && e.entry || null;
const entry = e && e.entry || null;
logger.debug('Auto type event', entry);
if (this.running) {
logger.debug('Already running, skipping event');
@ -67,12 +67,12 @@ var AutoType = {
run(entry, callback) {
this.running = true;
var sequence = entry.getEffectiveAutoTypeSeq();
const sequence = entry.getEffectiveAutoTypeSeq();
logger.debug('Start', sequence);
var ts = logger.ts();
const ts = logger.ts();
try {
var parser = new AutoTypeParser(sequence);
var runner = parser.parse();
const parser = new AutoTypeParser(sequence);
const runner = parser.parse();
logger.debug('Parsed', this.printOps(runner.ops));
runner.resolve(entry, err => {
if (err) {
@ -110,8 +110,8 @@ var AutoType = {
validate(entry, sequence, callback) {
try {
var parser = new AutoTypeParser(sequence);
var runner = parser.parse();
const parser = new AutoTypeParser(sequence);
const runner = parser.parse();
runner.resolve(entry, callback);
} catch (ex) {
return callback(ex);
@ -123,12 +123,12 @@ var AutoType = {
},
printOp(op) {
var mod = op.mod ? Object.keys(op.mod).join('') : '';
const mod = op.mod ? Object.keys(op.mod).join('') : '';
if (op.type === 'group') {
return mod + this.printOps(op.value);
}
if (op.type === 'text') {
var value = op.value;
let value = op.value;
if (!clearTextAutoTypeLog) {
value = value.replace(/./g, '*');
}
@ -161,8 +161,8 @@ var AutoType = {
selectEntryAndRun() {
this.getActiveWindowTitle((e, title, url) => {
let filter = new AutoTypeFilter({title, url}, this.appModel);
let evt = { filter };
const filter = new AutoTypeFilter({title, url}, this.appModel);
const evt = { filter };
if (!this.appModel.files.hasOpenFiles()) {
this.pendingEvent = evt;
this.appModel.files.once('update', this.processPendingEvent, this);
@ -179,7 +179,7 @@ var AutoType = {
},
processEventWithFilter(evt) {
let entries = evt.filter.getEntries();
const entries = evt.filter.getEntries();
if (entries.length === 1) {
this.hideWindow(() => {
this.runAndHandleResult(entries.at(0));
@ -216,7 +216,7 @@ var AutoType = {
return;
}
logger.debug('processing pending auto-type event');
let evt = this.pendingEvent;
const evt = this.pendingEvent;
this.appModel.files.off('update', this.processPendingEvent, this);
this.pendingEvent = null;
this.processEventWithFilter(evt);

View File

@ -1,10 +1,10 @@
'use strict';
var Backbone = require('backbone'),
EntryModel = require('../models/entry-model'),
Comparators = require('../util/comparators');
const Backbone = require('backbone');
const EntryModel = require('../models/entry-model');
const Comparators = require('../util/comparators');
var EntryCollection = Backbone.Collection.extend({
const EntryCollection = Backbone.Collection.extend({
model: EntryModel,
comparator: function() {},
@ -35,8 +35,8 @@ var EntryCollection = Backbone.Collection.extend({
},
attachmentSortVal: function(entry) {
var att = entry.attachments;
var str = att.length ? String.fromCharCode(64 + att.length) : 'Z';
const att = entry.attachments;
let str = att.length ? String.fromCharCode(64 + att.length) : 'Z';
if (att[0]) {
str += att[0].title;
}

View File

@ -1,9 +1,9 @@
'use strict';
var Backbone = require('backbone'),
FileModel = require('../models/file-model');
const Backbone = require('backbone');
const FileModel = require('../models/file-model');
var FileCollection = Backbone.Collection.extend({
const FileCollection = Backbone.Collection.extend({
model: FileModel,
hasOpenFiles: function() {

View File

@ -1,17 +1,17 @@
'use strict';
var Backbone = require('backbone'),
FileInfoModel = require('../models/file-info-model'),
SettingsStore = require('../comp/settings-store');
const Backbone = require('backbone');
const FileInfoModel = require('../models/file-info-model');
const SettingsStore = require('../comp/settings-store');
var FileInfoCollection = Backbone.Collection.extend({
const FileInfoCollection = Backbone.Collection.extend({
model: FileInfoModel,
initialize: function () {
},
load: function () {
var data = SettingsStore.load('file-info');
const data = SettingsStore.load('file-info');
if (data) {
this.reset(data, {silent: true});
}
@ -39,7 +39,7 @@ var FileInfoCollection = Backbone.Collection.extend({
});
FileInfoCollection.load = function() {
var coll = new FileInfoCollection();
const coll = new FileInfoCollection();
coll.load();
return coll;
};

View File

@ -1,9 +1,9 @@
'use strict';
var Backbone = require('backbone'),
GroupModel = require('../models/group-model');
const Backbone = require('backbone');
const GroupModel = require('../models/group-model');
var GroupCollection = Backbone.Collection.extend({
const GroupCollection = Backbone.Collection.extend({
model: GroupModel
});

View File

@ -1,9 +1,9 @@
'use strict';
var Backbone = require('backbone'),
MenuItemModel = require('../../models/menu/menu-item-model');
const Backbone = require('backbone');
const MenuItemModel = require('../../models/menu/menu-item-model');
var MenuItemCollection = Backbone.Collection.extend({
const MenuItemCollection = Backbone.Collection.extend({
model: MenuItemModel
});

View File

@ -1,9 +1,9 @@
'use strict';
var Backbone = require('backbone'),
MenuOptionModel = require('../../models/menu/menu-option-model');
const Backbone = require('backbone');
const MenuOptionModel = require('../../models/menu/menu-option-model');
var MenuOptionCollection = Backbone.Collection.extend({
const MenuOptionCollection = Backbone.Collection.extend({
model: MenuOptionModel
});

View File

@ -1,9 +1,9 @@
'use strict';
var Backbone = require('backbone'),
MenuSectionModel = require('../../models/menu/menu-section-model');
const Backbone = require('backbone');
const MenuSectionModel = require('../../models/menu/menu-section-model');
var MenuSectionCollection = Backbone.Collection.extend({
const MenuSectionCollection = Backbone.Collection.extend({
model: MenuSectionModel
});

View File

@ -1,9 +1,9 @@
'use strict';
var ModalView = require('../views/modal-view'),
Locale = require('../util/locale');
const ModalView = require('../views/modal-view');
const Locale = require('../util/locale');
var Alerts = {
const Alerts = {
alertDisplayed: false,
buttons: {
@ -18,7 +18,7 @@ var Alerts = {
return null;
}
Alerts.alertDisplayed = true;
var view = new ModalView({ model: config });
const view = new ModalView({ model: config });
view.render();
view.on('result', (res, check) => {
Alerts.alertDisplayed = false;

View File

@ -1,23 +1,23 @@
'use strict';
var DropboxLink = require('./dropbox-link');
const DropboxLink = require('./dropbox-link');
var AuthReceiver = {
const AuthReceiver = {
receive: function() {
var opener = window.opener || window.parent;
const opener = window.opener || window.parent;
if (location.href.indexOf('state=') >= 0) {
DropboxLink.receive();
} else {
var message = this.urlArgsToMessage(window.location.href);
const message = this.urlArgsToMessage(window.location.href);
opener.postMessage(message, window.location.origin);
window.close();
}
},
urlArgsToMessage: function(url) {
var message = {};
const message = {};
url.split(/[\?#&]/g).forEach(part => {
var parts = part.split('=');
const parts = part.split('=');
if (parts.length === 2) {
message[parts[0]] = parts[1];
}

View File

@ -1,16 +1,16 @@
'use strict';
var FeatureDetector = require('../util/feature-detector'),
Launcher = require('./launcher'),
AppSettingsModel = require('../models/app-settings-model');
const FeatureDetector = require('../util/feature-detector');
const Launcher = require('./launcher');
const AppSettingsModel = require('../models/app-settings-model');