From 070236b43c54a38bd60ecad901ed879befa455e5 Mon Sep 17 00:00:00 2001 From: Gustav Ahlberg Date: Fri, 11 Apr 2014 08:05:58 +0200 Subject: [PATCH] Added error message if dropbox content failed to be loaded --- scripts/OnePassword.js | 6 ++++-- scripts/popup.js | 2 ++ style/style.css | 1 - 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/OnePassword.js b/scripts/OnePassword.js index 981c6b7..78d5b78 100644 --- a/scripts/OnePassword.js +++ b/scripts/OnePassword.js @@ -11,6 +11,8 @@ Q.all([this.getContents(), this.getEncryptionKeys()]).then(function () { deferred.resolve(); + }, function () { + deferred.reject(); }); return deferred.promise; @@ -73,7 +75,7 @@ keychainItem.decrypt(keychain); }; - var getJson = function (url, cb) { + var getJson = function (url) { var deferred = Q.defer(); var xhr = new XMLHttpRequest(); @@ -89,7 +91,7 @@ }; xhr.onerror = function () { - cb(xhr.statusText); + deferred.reject(new Error(xhr.statusText)); }; xhr.send(); diff --git a/scripts/popup.js b/scripts/popup.js index a3ef7a3..a863256 100644 --- a/scripts/popup.js +++ b/scripts/popup.js @@ -28,6 +28,8 @@ onepassword = new window.OnePassword(items.baseurl); onepassword.load().then(function () { btnUnlock.disabled = false; + }, function () { + error.textContent = "Could not load onepassword data. Make sure you are logged in to dropbox and that the url is correct on the options page."; }); deferred.resolve(onepassword); diff --git a/style/style.css b/style/style.css index 3ce6fc1..7282398 100644 --- a/style/style.css +++ b/style/style.css @@ -60,7 +60,6 @@ .error { text-align: center; color: #f00; - height: 40px; margin-top: 10px; }