assets/js/dasht.js in dasht-0.1.3 vs assets/js/dasht.js in dasht-0.1.4
- old
+ new
@@ -25,10 +25,11 @@
}
Dasht.init = function() {
Dasht.scale_fontsize_loop();
Dasht.process_pending_requests_loop();
+ Dasht.watchdog_loop();
}
Dasht.fill_tile = function(el, do_width, do_height) {
var parent = $(el).parent();
if (do_width || do_width == undefined) {
@@ -105,10 +106,11 @@
queries.push(o);
});
Dasht.pending_requests = [];
var successFN = function(responses) {
+ Dasht.loaded_data = true;
$("body").removeClass("waiting");
// Process the responses.
_.each(responses, function(response, i) {
var query = queries[i];
@@ -130,6 +132,20 @@
type: 'post',
dataType: 'json',
data: JSON.stringify(queries),
success: successFN
});
+}
+
+
+Dasht.loaded_data = true;
+Dasht.watchdog_loop = function() {
+ // The page could get stuck for a variety of reasons. This is the
+ // last resort. Run every 2 minutes. If we haven't loaded new data
+ // in that time, then reload the page.
+ if (Dasht.loaded_data == true) {
+ Dasht.loaded_data = false;
+ setTimeout(Dasht.watchdog_loop, 2 * 60 * 1000);
+ } else {
+ document.location.reload();
+ }
}