/** * Internal function to remove content from the main area and add the notebook. * Not idempotent */ function append_notebook(url){ clear_main_area(); $('#main').append('' ); } function clear_main_area(){ $('#spinner').remove(); $('#main').children().remove(); } function display_spinner(){ $('#main').append(''); } /** * Test availability of a URL, and call a callback when done. * http://stackoverflow.com/q/25390206/347368 * @param {String} url: URL to test availability of. Must return a 200 (302->200 is OK). * @param {String} callback: function to call once successfully connected. * */ function test_ie_availability(url, success_callback){ var request_count = 0; display_spinner(); interval = setInterval(function(){ $.ajax({ url: url, xhrFields: { withCredentials: true }, type: "GET", timeout: 500, success: function(){ console.log("Connected to IE, returning"); clearInterval(interval); success_callback(); }, error: function(jqxhr, status, error){ request_count++; console.log("Request " + request_count); if(request_count > 30){ clearInterval(interval); clear_main_area(); toastr.error( "Could not connect to IE, contact your administrator", "Error", {'closeButton': true, 'timeOut': 20000, 'tapToDismiss': false} ); } } }); }, 1000); }