Permalink
Browse files

added link on notif.html for error handling

  • Loading branch information...
scottcheng committed Jun 13, 2012
1 parent 2498586 commit b19deac5ac59926da82c1c5a4e1e7e883cbdfa24
Showing with 26 additions and 13 deletions.
  1. +5 −1 _locales/en/messages.json
  2. +7 −7 background.js
  3. +1 −1 manifest.json
  4. +4 −1 notif.html
  5. +9 −3 notif.js
@@ -76,8 +76,12 @@
"description": "Text to display on the desktop notification on failing to saving a video"
},
- "notifLinkText": {
+ "notifLink": {
"message": "Visit Google Drive",
"description": "Text to display on the notification body"
+ },
+ "notifLinkError": {
+ "message": "Try again",
+ "description": "Text to display on the notification body when error occurs"
}
}
View
@@ -45,25 +45,25 @@ var saveToDrive = function(url, context) {
var target = 'https://docs.google.com/viewer?a=sv&url=' + encodeURIComponent(url);
$.get(target, function(data, textStatus, jqXHR) {
- onSaveSuccess(context, data, textStatus, jqXHR);
+ onSaveSuccess(context);
}, 'html').error(function(jqXHR, textStatus, errorThrown) {
- onSaveError(context, jqXHR, textStatus, errorThrown);
+ onSaveError(context, target);
});
};
var onSaveSuccess = function(context) {
_gaq.push(['_trackEvent', 'Save', 'succeed', context]);
- chrome.extension.getViews({type:"notification"}).forEach(function(notifWindow) {
+ chrome.extension.getViews({type: 'notification'}).forEach(function(notifWindow) {
notifWindow.onSaveSuccess();
});
};
-var onSaveError = function(context, textStatus) {
- _gaq.push(['_trackEvent', 'Save', 'fail', textStatus]);
+var onSaveError = function(context, target) {
+ _gaq.push(['_trackEvent', 'Save', 'fail', context]);
- chrome.extension.getViews({type:"notification"}).forEach(function(notifWindow) {
- notifWindow.onSaveError();
+ chrome.extension.getViews({type: 'notification'}).forEach(function(notifWindow) {
+ notifWindow.onSaveError(target);
});
};
View
@@ -1,6 +1,6 @@
{
"name": "__MSG_extName__",
- "version": "1.0.1",
+ "version": "1.0.2",
"description": "__MSG_extDesc__",
"permissions": [
"contextMenus",
View
@@ -29,14 +29,17 @@
}
#link2Drive {
color: #478CfE;
+}
+#link2Drive.error {
+ color: #EC4631;
}
</style>
</head>
<body>
<div id="notifIcon"></div>
<div id="textWrapper">
<div id="notifMsg"></div>
- <div><a id="link2Drive" href="https://drive.google.com/" target="_blank"></a></div>
+ <div><a id="link2Drive" target="_blank"></a></div>
</div>
<script type="text/javascript" src="lib/jquery.min.js"></script>
View
@@ -15,12 +15,18 @@ $link.click(function() {
});
var onSaveSuccess = function() {
- $link.html(chrome.i18n.getMessage('notifLinkText'));
+ $link
+ .html(chrome.i18n.getMessage('notifLink'))
+ .attr('href', 'https://drive.google.com/');
$msg.html(chrome.i18n.getMessage('notifSuc' + capitalise(context)));
startTimeout();
};
-var onSaveError = function() {
+var onSaveError = function(target) {
+ $link
+ .html(chrome.i18n.getMessage('notifLinkError'))
+ .attr('href', target)
+ .addClass('error');
$('#notifIcon').addClass('error');
$msg.html(chrome.i18n.getMessage('notifErr' + capitalise(context)));
startTimeout();
@@ -29,5 +35,5 @@ var onSaveError = function() {
var startTimeout = function() {
window.setTimeout(function() {
window.close();
- }, 3000);
+ }, 5000);
};

0 comments on commit b19deac

Please sign in to comment.