Skip to content
This repository has been archived by the owner on Jul 6, 2020. It is now read-only.

Commit

Permalink
move messages out of function creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernhard Posselt committed Feb 5, 2015
1 parent 55fc1e6 commit 77fccf6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 31 deletions.
28 changes: 13 additions & 15 deletions js/app/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,30 +44,28 @@ app.config(function ($routeProvider, $provide, $httpProvider) {
}
};
});
var errorMessages = {
0: t('news', 'Request failed, network connection unavailable!'),
401: t('news', 'Request unauthorized. Are you logged in?'),
403: t('news', 'Request forbidden. Are you an admin?'),
412: t('news', 'Token expired or app not enabled! Reload the page!'),
500: t('news', 'Internal server error! Please check your ' +
'data/owncloud.log file for additional ' +
'information!'),
503: t('news', 'Request failed, ownCloud is in currently ' +
'in maintenance mode!'),
};
$provide.factory('ConnectionErrorInterceptor', function ($q, $timeout) {
var timer;
return {
responseError: function (response) {
var messages = {
0: t('news', 'Request failed, network connection ' +
'unavailable!'),
401: t('news', 'Request unauthorized. Are you logged in?'),
403: t('news', 'Request forbidden. Are you an admin?'),
412: t('news', 'Token expired or app not enabled! ' +
'Try to reload the page!'),
500: t('news', 'Internal server error! Please check your ' +
'data/owncloud.log file for additional ' +
'information!'),
503: t('news', 'Request failed, ownCloud is in currently ' +
'in maintenance mode!'),
};
// status 0 is a network error
if (response.status in messages) {
if (response.status in errorMessages) {
if (timer) {
$timeout.cancel(timer);
}
OC.Notification.hide();
OC.Notification.showHtml(messages[response.status]);
OC.Notification.showHtml(errorMessages[response.status]);
timer = $timeout(function () {
OC.Notification.hide();
}, 5000);
Expand Down
28 changes: 13 additions & 15 deletions js/build/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,28 @@ app.config(["$routeProvider", "$provide", "$httpProvider", function ($routeProvi
}
};
}]);
var errorMessages = {
0: t('news', 'Request failed, network connection unavailable!'),
401: t('news', 'Request unauthorized. Are you logged in?'),
403: t('news', 'Request forbidden. Are you an admin?'),
412: t('news', 'Token expired or app not enabled! Reload the page!'),
500: t('news', 'Internal server error! Please check your ' +
'data/owncloud.log file for additional ' +
'information!'),
503: t('news', 'Request failed, ownCloud is in currently ' +
'in maintenance mode!'),
};
$provide.factory('ConnectionErrorInterceptor', ["$q", "$timeout", function ($q, $timeout) {
var timer;
return {
responseError: function (response) {
var messages = {
0: t('news', 'Request failed, network connection ' +
'unavailable!'),
401: t('news', 'Request unauthorized. Are you logged in?'),
403: t('news', 'Request forbidden. Are you an admin?'),
412: t('news', 'Token expired or app not enabled! ' +
'Try to reload the page!'),
500: t('news', 'Internal server error! Please check your ' +
'data/owncloud.log file for additional ' +
'information!'),
503: t('news', 'Request failed, ownCloud is in currently ' +
'in maintenance mode!'),
};
// status 0 is a network error
if (response.status in messages) {
if (response.status in errorMessages) {
if (timer) {
$timeout.cancel(timer);
}
OC.Notification.hide();
OC.Notification.showHtml(messages[response.status]);
OC.Notification.showHtml(errorMessages[response.status]);
timer = $timeout(function () {
OC.Notification.hide();
}, 5000);
Expand Down
Loading

0 comments on commit 77fccf6

Please sign in to comment.