summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorioguix2010-05-31 23:06:42 +0000
committerioguix2010-05-31 23:06:42 +0000
commit6d2d790391a18067d7a28698facdf94c6e519d07 (patch)
treefaf636fd27a5e09a440b942e9e372f690c6c4ad4 /js
parente3bc0f821fb22049f95d818de6b2c54180b8c507 (diff)
Better handling connection error and waiting in locks page behaviour on ajax request
* re-add error message on page * add a loading icon when a query is running * cancel ajax request when clicking on stop * preload image (start icon don't show up on error without it)
Diffstat (limited to 'js')
-rw-r--r--js/locks.js33
1 files changed, 29 insertions, 4 deletions
diff --git a/js/locks.js b/js/locks.js
index 81310e64..e069f1e9 100644
--- a/js/locks.js
+++ b/js/locks.js
@@ -1,20 +1,33 @@
$(document).ready(function() {
- var timeid = null;
+ var timeid = query = null;
var controlLink = $('#control');
+ var errmsg = $('<p class="errmsg">'+Database.errmsg+'</p>')
+ .insertBefore(controlLink)
+ .hide();
+ var loading = $('<img class="loading" alt="[loading]" src="'+ Database.load_icon +'" />')
+ .insertAfter(controlLink)
+ .hide();
function refreshLocksTable() {
if (Database.ajax_time_refresh > 0) {
- $.ajax({
+ loading.show();
+ query = $.ajax({
type: 'GET',
dataType: 'html',
url: 'database.php?action=refresh_locks&' + Database.server,
- timeout: Database.ajax_timeout - 100,
cache: false,
contentType: 'application/x-www-form-urlencoded',
success: function(html) {
$('#locks_block').html(html);
timeid = window.setTimeout(refreshLocksTable, Database.ajax_time_refresh)
+ },
+ error: function() {
+ controlLink.click();
+ errmsg.show();
+ },
+ complete: function () {
+ loading.hide();
}
});
}
@@ -22,17 +35,29 @@ $(document).ready(function() {
controlLink.toggle(
function() {
+ $(errmsg).hide();
timeid = window.setTimeout(refreshLocksTable, Database.ajax_time_refresh);
controlLink.html('<img src="'+ Database.str_stop.icon +'" alt="" />&nbsp;'
- + Database.str_stop.text);
+ + Database.str_stop.text + '&nbsp;&nbsp;&nbsp;'
+ );
},
function() {
+ $(errmsg).hide();
+ $(loading).hide();
window.clearInterval(timeid);
+ query.abort();
controlLink.html('<img src="'+ Database.str_start.icon +'" alt="" />&nbsp;'
+ Database.str_start.text
);
}
);
+ /* preload images */
+ $('#control img').hide()
+ .attr('src', Database.str_start.icon)
+ .attr('src', Database.str_stop.icon)
+ .show();
+
+ /* start refreshing */
controlLink.click();
});