Skip to content

Instantly share code, notes, and snippets.

@Carreau
Created November 29, 2014 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Carreau/682b52d75dacc5ab4fbb to your computer and use it in GitHub Desktop.
Save Carreau/682b52d75dacc5ab4fbb to your computer and use it in GitHub Desktop.
// Add help panel at right side of notebook window
"using strict";
var help_panel_extension = (function() {
toggleHelpPanel = function () {
/* check if help panel is already there */
var link = $('<a/>').text('clickme')
link.on('click', function(){IPython.notebook.kernel.execute(
'"Hi there"',
{
shell : {
reply : function(data){console.log('reply',data.content)},
payload : {
set_next_input : function(data){console.log('sni',data)},
page : function(data){console.log('page',data)},
}
},
iopub : {
output : function(data){$("#helpPanel").append(data.content.data['text/plain']); console.log('output',data.content)},
clear_output : function(data){console.log('cloup',data)},
},
input : function(data){console.log('rawin',data)}
}
, {silent: false, store_history: true})})
var a= $("#helpPanel").html();
if ( a == undefined ) {
$("#notebook_panel").css({"float": "left","overflow-x": "hidden","height": "100%","width": "70%","font-size": "9pt"});
var helppanel = '<div id="helpPanel"></div>';
$("#ipython-main-app").append(helppanel);
$('#helpPanel').append(link);
}
else {
$("#notebook_panel").css({"width": "100%"});
$('#helpPanel').remove();
}
};
IPython.toolbar.add_buttons_group([
{
id : 'help_panel',
label : 'Show help panel',
icon : 'icon-book fa fa-book',
callback : toggleHelpPanel
}
]);
var scripts = document.getElementsByTagName("script");
var scriptLocation = scripts[scripts.length - 1].src;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment