1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-11-06 01:15:05 -05:00
SickRage/gui/slick/js/restart.js
echel0n 0d9fbc1ad7 Welcome to our SickBeard-TVRage Edition ...
This version of SickBeard uses both TVDB and TVRage to search and gather it's series data from allowing you to now have access to and download shows that you couldn't before because of being locked into only what TheTVDB had to offer.

Also this edition is based off the code we used in our XEM editon so it does come with scene numbering support as well as all the other features our XEM edition has to offer.

Please before using this with your existing database (sickbeard.db) please make a backup copy of it and delete any other database files such as cache.db and failed.db if present, we HIGHLY recommend starting out with no database files at all to make this a fresh start but the choice is at your own risk!

Enjoy!
2014-03-09 22:39:12 -07:00

79 lines
2.7 KiB
JavaScript

if (sbHttpsEnabled != "False" && sbHttpsEnabled != 0)
var sb_base_url = 'https://'+sbHost+':'+sbHttpPort+sbRoot;
else
var sb_base_url = 'http://'+sbHost+':'+sbHttpPort+sbRoot;
var base_url = window.location.protocol+'//'+window.location.host+sbRoot;
var is_alive_url = sbRoot+'/home/is_alive';
var timeout_id;
var current_pid = '';
var num_restart_waits = 0;
function is_alive() {
timeout_id = 0;
$.get(is_alive_url, function(data) {
// if it's still initalizing then just wait and try again
if (data.msg == 'nope') {
$('#shut_down_loading').hide();
$('#shut_down_success').show();
$('#restart_message').show();
setTimeout('is_alive()', 1000);
} else {
// if this is before we've even shut down then just try again later
if (current_pid == '' || data.msg == current_pid) {
current_pid = data.msg;
setTimeout(is_alive, 1000);
// if we're ready to go then redirect to new url
} else {
$('#restart_loading').hide();
$('#restart_success').show();
$('#refresh_message').show();
window.location = sb_base_url+'/home';
}
}
}, 'jsonp');
}
$(document).ready(function()
{
is_alive();
$(document).ajaxError(function(e, jqxhr, settings, exception) {
num_restart_waits += 1;
$('#shut_down_loading').hide();
$('#shut_down_success').show();
$('#restart_message').show();
is_alive_url = sb_base_url+'/home/is_alive';
// if https is enabled or you are currently on https and the port or protocol changed just wait 5 seconds then redirect.
// This is because the ajax will fail if the cert is untrusted or the the http ajax requst from https will fail because of mixed content error.
if ((sbHttpsEnabled != "False" && sbHttpsEnabled != 0) || window.location.protocol == "https:") {
if (base_url != sb_base_url) {
timeout_id = 1;
setTimeout(function(){
$('#restart_loading').hide();
$('#restart_success').show();
$('#refresh_message').show();
}, 3000);
setTimeout("window.location = sb_base_url+'/home'", 5000);
}
}
// if it is taking forever just give up
if (num_restart_waits > 90) {
$('#restart_loading').hide();
$('#restart_failure').show();
$('#restart_fail_message').show();
return;
}
if (timeout_id == 0)
timeout_id = setTimeout('is_alive()', 1000);
});
});