diff options
author | m3ntalsp00n <m3ntalsp00n@gmail.com> | 2017-02-04 15:47:09 +1000 |
---|---|---|
committer | m3ntalsp00n <m3ntalsp00n@gmail.com> | 2017-02-04 15:47:09 +1000 |
commit | fd40613d8ebae128ef72576ff6243fe2da37b06a (patch) | |
tree | d8c92843f3e6f1f59790663aeea3724e3ca0b4a3 | |
parent | 03bbda913dc5f9a4fcacb39e0ba854bd1eab8851 (diff) | |
download | nextcloud-server-fd40613d8ebae128ef72576ff6243fe2da37b06a.tar.gz nextcloud-server-fd40613d8ebae128ef72576ff6243fe2da37b06a.zip |
showUpdate funciton allows updated messages
Signed-off-by: m3ntalsp00n <m3ntalsp00n@gmail.com>
-rw-r--r-- | core/js/js.js | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/core/js/js.js b/core/js/js.js index 3651635541a..0576dcc3357 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -780,8 +780,18 @@ var OCP = {}, // sometimes "beforeunload" happens later, so need to defer the reload a bit setTimeout(function() { if (!self._userIsNavigatingAway && !self._reloadCalled) { - OC.Notification.show(t('core', 'Problem loading page, reloading in 5 seconds')); - setTimeout(OC.reload, 5000); + var timer = 0; + var seconds = 5; + var interval = setInterval( function() { + OC.Notification.showUpdate(t('core', 'Problem loading page, reloading in ' + (seconds - timer) + ' seconds')); + if (timer >= seconds) { + clearInterval(interval); + OC.reload(); + } + timer++; + }, 1000 // 1 second interval + ); + // only call reload once self._reloadCalled = true; } @@ -1174,6 +1184,30 @@ OC.Notification={ }, /** + * Updates (replaces) a sanitized notification. + * + * @param {string} text Message to display + * @return {jQuery} JQuery element for notificaiton row + */ + showUpdate: function(text) { + var $notification = $('#notification'); + // sanitise + var $html = $('<div/>').text(text).html(); + + // new notification + if (text && $notification.find('.row').length == 0) { + return this.showHtml($html); + } + + var $row = $('<div class="row"></div>').prepend($html); + + // just update html in notification + $notification.html($row); + + return $row; + }, + + /** * Shows a notification that disappears after x seconds, default is * 7 seconds * |