aboutsummaryrefslogtreecommitdiffstats
path: root/core/js/js.js
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2019-05-15 10:37:11 +0200
committerChristoph Wurst <christoph@winzerhof-wurst.at>2019-05-15 10:40:15 +0200
commitab72bd64f566b0575d319a5375b9bdf7fc8b16fa (patch)
tree0921e5ca0bd915f8fab6e1ac303a60f30c1c894c /core/js/js.js
parentb5fed5981295eacd8a78b4aefa0c2309357fc44c (diff)
downloadnextcloud-server-ab72bd64f566b0575d319a5375b9bdf7fc8b16fa.tar.gz
nextcloud-server-ab72bd64f566b0575d319a5375b9bdf7fc8b16fa.zip
Move legacy Ajax error handling logic to the bundle
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'core/js/js.js')
-rw-r--r--core/js/js.js86
1 files changed, 0 insertions, 86 deletions
diff --git a/core/js/js.js b/core/js/js.js
index 8b9fae0a921..7d449a324d2 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -5,91 +5,5 @@ Object.assign(window.OC, {
/* jshint camelcase: false */
/**
- * Warn users that the connection to the server was lost temporarily
- *
- * This function is throttled to prevent stacked notfications.
- * After 7sec the first notification is gone, then we can show another one
- * if necessary.
- */
- _ajaxConnectionLostHandler: _.throttle(function() {
- OC.Notification.showTemporary(t('core', 'Connection to server lost'));
- }, 7 * 1000, {trailing: false}),
-
- /**
- * Process ajax error, redirects to main page
- * if an error/auth error status was returned.
- */
- _processAjaxError: function(xhr) {
- var self = this;
- // purposefully aborted request ?
- // this._userIsNavigatingAway needed to distinguish ajax calls cancelled by navigating away
- // from calls cancelled by failed cross-domain ajax due to SSO redirect
- if (xhr.status === 0 && (xhr.statusText === 'abort' || xhr.statusText === 'timeout' || self._reloadCalled)) {
- return;
- }
-
- if (_.contains([302, 303, 307, 401], xhr.status) && OC.currentUser) {
- // sometimes "beforeunload" happens later, so need to defer the reload a bit
- setTimeout(function() {
- if (!self._userIsNavigatingAway && !self._reloadCalled) {
- var timer = 0;
- var seconds = 5;
- var interval = setInterval( function() {
- OC.Notification.showUpdate(n('core', 'Problem loading page, reloading in %n second', 'Problem loading page, reloading in %n seconds', seconds - timer));
- if (timer >= seconds) {
- clearInterval(interval);
- OC.reload();
- }
- timer++;
- }, 1000 // 1 second interval
- );
-
- // only call reload once
- self._reloadCalled = true;
- }
- }, 100);
- } else if(xhr.status === 0) {
- // Connection lost (e.g. WiFi disconnected or server is down)
- setTimeout(function() {
- if (!self._userIsNavigatingAway && !self._reloadCalled) {
- self._ajaxConnectionLostHandler();
- }
- }, 100);
- }
- },
-
- /**
- * Registers XmlHttpRequest object for global error processing.
- *
- * This means that if this XHR object returns 401 or session timeout errors,
- * the current page will automatically be reloaded.
- *
- * @param {XMLHttpRequest} xhr
- */
- registerXHRForErrorProcessing: function(xhr) {
- var loadCallback = function() {
- if (xhr.readyState !== 4) {
- return;
- }
-
- if (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) {
- return;
- }
-
- // fire jquery global ajax error handler
- $(document).trigger(new $.Event('ajaxError'), xhr);
- };
-
- var errorCallback = function() {
- // fire jquery global ajax error handler
- $(document).trigger(new $.Event('ajaxError'), xhr);
- };
-
- if (xhr.addEventListener) {
- xhr.addEventListener('load', loadCallback);
- xhr.addEventListener('error', errorCallback);
- }
-
- }
});