Skip to content

Commit

Permalink
Minor feature: Modal warnings for pause / update error + attempt restart
Browse files Browse the repository at this point in the history
  • Loading branch information
tvroom committed Oct 15, 2008
1 parent bf0fea6 commit c99e9e9
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions plugins/Ajax/htdocs/images/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,10 @@ function ajax_update(request_params, id, handlers, options) {
opts.complete = handlers.onComplete;
}

if ( handlers && handlers.onError ) {
opts.error = handlers.onError;
}

jQuery.ajax(opts);
}

Expand Down Expand Up @@ -1230,7 +1234,13 @@ function firehose_get_updates(options) {
}

$('.busy').show();
ajax_update(params, '', { onComplete: firehose_get_updates_handler });
ajax_update(params, '', { onComplete: firehose_get_updates_handler, onError: firehose_updates_error_handler });
}

function firehose_updates_error_handler(XMLHttpRequest, textStatus, errorThrown) {
if (fh_is_admin) {
firehose_update_failed_modal();
}
}

function setFirehoseAction() {
Expand Down Expand Up @@ -1271,11 +1281,17 @@ function run_before_update() {
var secs = getSecsSinceLastFirehoseAction();
if (secs > inactivity_timeout) {
fh_is_timed_out = 1;
$('#message_area').html("Automatic updates have been slowed due to inactivity");
//firehose_pause();
firehose_inactivity_modal();
}
}

function firehose_inactivity_modal() {
$('#preference_title').html('Firehose Paused due to inactivity');
show_modal_box();
$('#modal_box_content').html("<a href='#' onclick='setFirehoseAction();hide_modal_box()'>Click to unpause</a>");
show_modal_box();
}

function firehose_play() {
fh_play = 1;
setFirehoseAction();
Expand Down Expand Up @@ -1596,6 +1612,17 @@ function firehose_get_media_popup(id) {
}, 'modal_box_content');
}

function firehose_reinit_updates() {
fh_is_updating = 0;
firehose_add_update_timerid(setTimeout(firehose_get_updates, 5000));
}

function firehose_update_failed_modal() {
$('#preference_title').html('Firehose updates failed');
$('#modal_box_content').html('Update failed or timed out. <a href="#" onclick="firehose_reinit_updates();hide_modal_box();">Click to retry</a>');
show_modal_box();
}

function saveModalPrefs() {
var params = {};
params.op = 'saveModalPrefs';
Expand Down

0 comments on commit c99e9e9

Please sign in to comment.