Files
galaxy/static/scripts/galaxy.interactive_environments.js
T
John Chilton 5547bb7df5 Refactor interactive environment plugin framework out of IPython and into Galaxy.
Rely on more Python and less on mako, setup a small shared common mako file in config/plugins/interactive_environments/common/ie.mako. Move ie.js into client/galaxy/scripts/galaxy.interactive_environments.js and extract IPython's require config out so it doesn't have to directly reference client/galaxy/scripts/galaxy.interactive_environments.js (I doubt it is where that file actually should be).
2014-10-18 18:38:04 -04:00

60 lines
1.9 KiB
JavaScript

/**
* Internal function to remove content from the main area and add the notebook.
* Not idempotent
*/
function append_notebook(url){
clear_main_area();
$('#main').append('<iframe frameBorder="0" seamless="seamless" style="width: 100%; height: 100%; overflow:hidden;" scrolling="no" src="'+ url +'"></iframe>'
);
}
function clear_main_area(){
$('#spinner').remove();
$('#main').children().remove();
}
function display_spinner(){
$('#main').append('<img id="spinner" src="' + galaxy_root + '/static/style/largespinner.gif" style="position:absolute;margin:auto;top:0;left:0;right:0;bottom:0;">');
}
/**
* 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);
}