From 8da25d516072543dc5526821898132876ea7e43e Mon Sep 17 00:00:00 2001 From: Zubaidullo Date: Sat, 7 Apr 2018 17:22:06 +0600 Subject: [PATCH] #62: improve enter key password pop-up menu messages and size --- common/lib/controller/pwd.controller.js | 2 +- common/lib/pgpModel.js | 5 +++++ common/ui/inline/encryptFrame.js | 14 ++++++++---- common/ui/inline/main-cs.js | 22 ++++++++++++++++++- .../ui/modal/_popup-enter-key-password.html | 2 +- locales/en/messages.json | 2 +- 6 files changed, 39 insertions(+), 8 deletions(-) diff --git a/common/lib/controller/pwd.controller.js b/common/lib/controller/pwd.controller.js index 5cef73c..ac44d87 100755 --- a/common/lib/controller/pwd.controller.js +++ b/common/lib/controller/pwd.controller.js @@ -147,7 +147,7 @@ define(function(require, exports, module) { that.options.beforePasswordRequest(); } if (that.options.openPopup) { - that.porto.windows.openPopup('common/ui/modal/_popup-enter-key-password.html?id=' + that.id, {width: 470, height: 327, modal: false}, function(window) { + that.porto.windows.openPopup('common/ui/modal/_popup-enter-key-password.html?id=' + that.id, {width: 470, height: 355, modal: false}, function(window) { that.pwdPopup = window; }); } diff --git a/common/lib/pgpModel.js b/common/lib/pgpModel.js index 7d0101c..c06693d 100755 --- a/common/lib/pgpModel.js +++ b/common/lib/pgpModel.js @@ -262,6 +262,11 @@ define(function(require, exports, module) { * @return {Promise} */ function signMessage(message, signKey) { + console.log("-------------------------"); + console.log("sign message"); + console.log(message); + console.log(signKey); + console.log("-------------------------"); return openpgp.getWorker().signClearMessage([signKey], message); } diff --git a/common/ui/inline/encryptFrame.js b/common/ui/inline/encryptFrame.js index 73824aa..5ba6ccd 100755 --- a/common/ui/inline/encryptFrame.js +++ b/common/ui/inline/encryptFrame.js @@ -26,6 +26,10 @@ porto.EncryptFrame = function(prefs) { }; porto.EncryptFrame.prototype.attachTo = function(element, options) { + console.log("encryptFrame.js - prototype.attachTo"); + console.log("Element: %s", element); + console.log("Options: %s", options); + $.extend(this._options, options); this._init(element); this._establishConnection(); @@ -389,13 +393,14 @@ porto.EncryptFrame.prototype._getEmailRecipient = function() { * @param {string} msg txt or html content */ porto.EncryptFrame.prototype._setMessage = function(msg, type, fingerprint) { + console.log("encryptFrame -> prototype._setMessage"); if (this._emailTextElement.is('textarea')) { // decode HTML entities for type text due to previous HTML parsing msg = porto.util.decodeHTML(msg); this._emailTextElement.val(msg); $(this._emailTextElement).text(msg); - //console.log(msg); - //this._emailTextElement.removeClass('bp-set-pub-key'); + // console.log(msg); + // this._emailTextElement.removeClass('bp-set-pub-key'); var signTargets = document.getElementsByClassName('bp-sign-target'); if (signTargets.length > 0) { @@ -404,7 +409,7 @@ porto.EncryptFrame.prototype._setMessage = function(msg, type, fingerprint) { signTargets[0].dispatchEvent(changeEvent); } catch (err) { - //console.error(err); + console.error(err); } } $(this._emailTextElement).removeClass('bp-sign-target'); @@ -451,8 +456,9 @@ porto.EncryptFrame.prototype._resetEmailText = function() { porto.EncryptFrame.prototype._registerEventListener = function() { var that = this; + console.log(that); this._port.onMessage.addListener(function(msg) { - //console.log('eFrame-%s event %s received', that.id, msg.event); + console.log('E-Frame | Event - [%s] ', msg.event); switch (msg.event) { case 'encrypt-dialog-cancel': case 'sign-dialog-cancel': diff --git a/common/ui/inline/main-cs.js b/common/ui/inline/main-cs.js index e46a20d..c571622 100755 --- a/common/ui/inline/main-cs.js +++ b/common/ui/inline/main-cs.js @@ -16,6 +16,7 @@ porto.util.csGetHash().then(function(hash) { porto.main.port = null; porto.main.connect = function() { + console.log("main-cs.js -> connect"); if (document.portoControl) { return; } @@ -56,6 +57,7 @@ porto.main.off = function() { }; porto.main.scanLoop = function() { + console.log("[ SCAN ]"); // find armored PGP text var pgpTag = porto.main.findPGPTag(porto.main.regex); if (pgpTag.length !== 0) { @@ -64,6 +66,8 @@ porto.main.scanLoop = function() { // find editable content var editable = porto.main.findEditable(); if (editable.length !== 0) { + console.log("SCAN -> found editable content"); + console.log(editable); porto.main.attachEncryptFrame(editable); } }; @@ -179,6 +183,8 @@ porto.main.getMessageType = function(armored) { }; porto.main.attachExtractFrame = function(element) { + console.log("main-cs.js -> attachExtractFrame"); + // check status of PGP tags var newObj = element.filter(function() { return !porto.ExtractFrame.isAttached($(this).parent()); @@ -213,9 +219,15 @@ porto.main.attachExtractFrame = function(element) { * @param {boolean} expanded state of frame */ porto.main.attachEncryptFrame = function(element, expanded) { + console.log("main-cs.js -> attachEncryptFrame"); + + console.log(element); + console.log(expanded); // check status of elements + //TODO expanded is sometimes UNDEFINED var newObj = element.filter(function() { if (expanded) { + console.log("expanded"); // filter out only attached frames if (element.data(porto.FRAME_STATUS) === porto.FRAME_ATTACHED) { // trigger expand state of attached frames @@ -225,15 +237,20 @@ porto.main.attachEncryptFrame = function(element, expanded) { return true; } } else { + console.log("not expanded"); // filter out attached and detached frames return !porto.EncryptFrame.isAttached($(this)); } }); + console.log("next"); // create new encrypt frames for new discovered editable fields newObj.each(function(index, element) { + console.log("newObj -> each"); new porto.EncryptFrame(porto.main.prefs).then(function(frame) { var eFrame = frame; + console.log(element); if ($(element).hasClass('bp-sign-target')) { + console.log("main-cs.js -> attachEncryptFrame -> has class bp-sign-target"); eFrame.attachTo($(element), { expanded: expanded, su_fingerprint: getCookie('su_fingerprint'), @@ -277,9 +294,10 @@ function getCookie(cname) { } porto.main.addMessageListener = function() { + console.log("main-cs.js -> addMessageListener"); porto.main.port.onMessage.addListener( function(request) { - //console.log('contentscript: %s onRequest: %o', document.location.toString(), request); + console.log('contentscript: %s onRequest: %o', document.location.toString(), request); if (request.event === undefined) { return; } @@ -296,6 +314,8 @@ porto.main.addMessageListener = function() { break; case 'context-encrypt': if (porto.main.contextTarget !== null) { + console.log("main-cs.js -> addMessageListener -> context-encrypt"); + porto.main.attachEncryptFrame(porto.main.contextTarget, true); porto.main.contextTarget = null; } diff --git a/common/ui/modal/_popup-enter-key-password.html b/common/ui/modal/_popup-enter-key-password.html index 9653f08..4057368 100755 --- a/common/ui/modal/_popup-enter-key-password.html +++ b/common/ui/modal/_popup-enter-key-password.html @@ -36,7 +36,7 @@
-
- + diff --git a/locales/en/messages.json b/locales/en/messages.json index 7caa1b3..3a22261 100755 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -140,7 +140,7 @@ "description": "Title of the password dialog." }, "pwd_dialog_header": { - "message": "Enter key password", + "message": "The key you're using is password protected by the Subutai E2E plugin", "description": "Header of the password dialog." }, "pwd_dialog_userid": {