$(document).ready(function () {
IPython.page = new IPython.Page();
$('#new_notebook').button().click(function (e) {
IPython.notebook_list.new_notebook()
});
var opts = {
base_url : IPython.utils.get_body_data("baseUrl"),
notebook_path : IPython.utils.get_body_data("notebookPath"),
};
IPython.session_list = new IPython.SesssionList(opts);
IPython.notebook_list = new IPython.NotebookList('#notebook_list', opts);
IPython.cluster_list = new IPython.ClusterList('#cluster_list', opts);
IPython.kernel_list = new IPython.KernelList('#running_list', opts);
IPython.login_widget = new IPython.LoginWidget('#login_widget', opts);
var interval_id=0;
var time_refresh = 60;
var enable_autorefresh = function(){
if($('.upload_button').length == 0)
{
IPython.session_list.load_sessions();
IPython.cluster_list.load_list();
}
if (!interval_id){
interval_id = setInterval(function(){
if($('.upload_button').length == 0)
{
IPython.session_list.load_sessions();
IPython.cluster_list.load_list();
}
}, time_refresh*1000);
}
}
var disable_autorefresh = function(){
clearInterval(interval_id);
interval_id = 0;
}
$(window).blur(function() {
disable_autorefresh();
})
$(window).focus(function() {
enable_autorefresh();
});
enable_autorefresh();
IPython.page.show();
$("#alternate_upload").change(function (event){
IPython.notebook_list.handleFilesUpload(event,'form');
});
$("#tabs").find("a").click(function() {
window.location.hash = $(this).attr("href");
})
if (window.location.hash) {
$("#tabs").find("a[href=" + window.location.hash + "]").click();
}
});