From 0a201ef8875acbb0d8fdfbf3f330823e3759c2db Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 14 Sep 2016 22:14:06 -0400 Subject: [PATCH] handle success and error conditions when autofilling current tab --- src/popup/app/current/currentController.js | 19 ++++++++++++------- src/popup/less/plugins.less | 1 + 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/popup/app/current/currentController.js b/src/popup/app/current/currentController.js index 835ca43e..6bf8fc17 100644 --- a/src/popup/app/current/currentController.js +++ b/src/popup/app/current/currentController.js @@ -1,7 +1,7 @@ angular .module('bit.current') - .controller('currentController', function ($scope, siteService, cipherService, tldjs, toastr, $q) { + .controller('currentController', function ($scope, siteService, cipherService, tldjs, toastr, $q, $window) { var pageDetails = null, tabId = null; $scope.canAutofill = false; @@ -95,7 +95,12 @@ angular chrome.tabs.sendMessage(tabId, { command: 'fillForm', fillScript: fillScript - }, function () { }); + }, function () { + $window.close() + }); + } + else { + toastr.error('Unable to auto-fill the selected site. Copy/paste your username and/or password instead.'); } }; @@ -143,12 +148,12 @@ angular // First let's try to guess the correct login form by examining the form attribute strings // for common login form attribute. for (i = 0; i < passwordForms.length; i++) { - var formDescriptor = (passwordForms[i].htmlName + '~' + passwordForms[i].htmlId - + '~' + passwordForms[i].htmlAction).toLowerCase(); + var formDescriptor = (passwordForms[i].htmlName + '~' + passwordForms[i].htmlId + + '~' + passwordForms[i].htmlAction).toLowerCase(); - if (formDescriptor.indexOf('login') !== -1 || formDescriptor.indexOf('log-in') !== -1 - || formDescriptor.indexOf('signin') !== -1 || formDescriptor.indexOf('sign-in') !== -1 - || formDescriptor.indexOf('logon') !== -1 || formDescriptor.indexOf('log-on') !== -1) { + if (formDescriptor.indexOf('login') !== -1 || formDescriptor.indexOf('log-in') !== -1 || + formDescriptor.indexOf('signin') !== -1 || formDescriptor.indexOf('sign-in') !== -1 || + formDescriptor.indexOf('logon') !== -1 || formDescriptor.indexOf('log-on') !== -1) { loginForm = passwordForms[i]; break; } diff --git a/src/popup/less/plugins.less b/src/popup/less/plugins.less index 2caea14f..f5776576 100644 --- a/src/popup/less/plugins.less +++ b/src/popup/less/plugins.less @@ -10,6 +10,7 @@ } .toast { + opacity: 1 !important; background-image: none !important; border-radius: 0; .box-shadow(0 0 8px rgba(0, 0, 0, 0.5));