mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-09 17:37:02 +03:00
eslint (additional rules)
This commit is contained in:
parent
77a1d3f3df
commit
8e8a041032
150 changed files with 21911 additions and 23106 deletions
|
|
@ -1,132 +1,124 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
'use strict';
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
PgpStore = require('Stores/User/Pgp'),
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
PgpStore = require('Stores/User/Pgp'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function NewOpenPgpKeyPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsNewOpenPgpKey');
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
this.email = ko.observable('');
|
||||
this.email.focus = ko.observable('');
|
||||
this.email.error = ko.observable(false);
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function NewOpenPgpKeyPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsNewOpenPgpKey');
|
||||
this.name = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
this.keyBitLength = ko.observable(2048);
|
||||
|
||||
this.email = ko.observable('');
|
||||
this.email.focus = ko.observable('');
|
||||
this.email.error = ko.observable(false);
|
||||
this.submitRequest = ko.observable(false);
|
||||
|
||||
this.name = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
this.keyBitLength = ko.observable(2048);
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
|
||||
this.email.subscribe(function () {
|
||||
this.email.error(false);
|
||||
}, this);
|
||||
|
||||
this.generateOpenPgpKeyCommand = Utils.createCommand(this, function () {
|
||||
|
||||
var
|
||||
self = this,
|
||||
oUserId = {},
|
||||
oOpenpgpKeyring = PgpStore.openpgpKeyring
|
||||
;
|
||||
|
||||
this.email.error('' === Utils.trim(this.email()));
|
||||
if (!oOpenpgpKeyring || this.email.error())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
oUserId.email = this.email();
|
||||
if ('' !== this.name())
|
||||
{
|
||||
oUserId.name = this.name();
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
_.delay(function () {
|
||||
|
||||
var mPromise = false;
|
||||
|
||||
try {
|
||||
|
||||
mPromise = PgpStore.openpgp.generateKey({
|
||||
userIds: [oUserId],
|
||||
numBits: Utils.pInt(self.keyBitLength()),
|
||||
passphrase: Utils.trim(self.password())
|
||||
});
|
||||
|
||||
mPromise.then(function (mKeyPair) {
|
||||
|
||||
self.submitRequest(false);
|
||||
|
||||
if (mKeyPair && mKeyPair.privateKeyArmored)
|
||||
{
|
||||
oOpenpgpKeyring.privateKeys.importKey(mKeyPair.privateKeyArmored);
|
||||
oOpenpgpKeyring.publicKeys.importKey(mKeyPair.publicKeyArmored);
|
||||
|
||||
oOpenpgpKeyring.store();
|
||||
|
||||
require('App/User').default.reloadOpenPgpKeys();
|
||||
Utils.delegateRun(self, 'cancelCommand');
|
||||
}
|
||||
|
||||
}).then(null, function() {
|
||||
self.submitRequest(false);
|
||||
});
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
Utils.log(e);
|
||||
self.submitRequest(false);
|
||||
}
|
||||
|
||||
}, 100);
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/NewOpenPgpKey', 'PopupsNewOpenPgpKeyViewModel'], NewOpenPgpKeyPopupView);
|
||||
_.extend(NewOpenPgpKeyPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
NewOpenPgpKeyPopupView.prototype.clearPopup = function ()
|
||||
{
|
||||
this.name('');
|
||||
this.password('');
|
||||
|
||||
this.email('');
|
||||
this.email.subscribe(function() {
|
||||
this.email.error(false);
|
||||
this.keyBitLength(2048);
|
||||
};
|
||||
}, this);
|
||||
|
||||
NewOpenPgpKeyPopupView.prototype.onShow = function ()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
this.generateOpenPgpKeyCommand = Utils.createCommand(this, function() {
|
||||
|
||||
NewOpenPgpKeyPopupView.prototype.onShowWithDelay = function ()
|
||||
{
|
||||
this.email.focus(true);
|
||||
};
|
||||
var
|
||||
self = this,
|
||||
oUserId = {},
|
||||
oOpenpgpKeyring = PgpStore.openpgpKeyring;
|
||||
|
||||
module.exports = NewOpenPgpKeyPopupView;
|
||||
this.email.error('' === Utils.trim(this.email()));
|
||||
if (!oOpenpgpKeyring || this.email.error())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}());
|
||||
oUserId.email = this.email();
|
||||
if ('' !== this.name())
|
||||
{
|
||||
oUserId.name = this.name();
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
_.delay(function() {
|
||||
|
||||
var mPromise = false;
|
||||
|
||||
try {
|
||||
|
||||
mPromise = PgpStore.openpgp.generateKey({
|
||||
userIds: [oUserId],
|
||||
numBits: Utils.pInt(self.keyBitLength()),
|
||||
passphrase: Utils.trim(self.password())
|
||||
});
|
||||
|
||||
mPromise.then(function(mKeyPair) {
|
||||
|
||||
self.submitRequest(false);
|
||||
|
||||
if (mKeyPair && mKeyPair.privateKeyArmored)
|
||||
{
|
||||
oOpenpgpKeyring.privateKeys.importKey(mKeyPair.privateKeyArmored);
|
||||
oOpenpgpKeyring.publicKeys.importKey(mKeyPair.publicKeyArmored);
|
||||
|
||||
oOpenpgpKeyring.store();
|
||||
|
||||
require('App/User').default.reloadOpenPgpKeys();
|
||||
Utils.delegateRun(self, 'cancelCommand');
|
||||
}
|
||||
|
||||
}).then(null, function() {
|
||||
self.submitRequest(false);
|
||||
});
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
Utils.log(e);
|
||||
self.submitRequest(false);
|
||||
}
|
||||
|
||||
}, 100);
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/NewOpenPgpKey', 'PopupsNewOpenPgpKeyViewModel'], NewOpenPgpKeyPopupView);
|
||||
_.extend(NewOpenPgpKeyPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
NewOpenPgpKeyPopupView.prototype.clearPopup = function()
|
||||
{
|
||||
this.name('');
|
||||
this.password('');
|
||||
|
||||
this.email('');
|
||||
this.email.error(false);
|
||||
this.keyBitLength(2048);
|
||||
};
|
||||
|
||||
NewOpenPgpKeyPopupView.prototype.onShow = function()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
NewOpenPgpKeyPopupView.prototype.onShowWithDelay = function()
|
||||
{
|
||||
this.email.focus(true);
|
||||
};
|
||||
|
||||
module.exports = NewOpenPgpKeyPopupView;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue