ROOT  6.06/09
Reference Guide
custom.js
Go to the documentation of this file.
1 /* ROOTaaS JS */
2 
3 highlight_cells = function(IPython, mime) {
4  IPython.CodeCell.options_default.cm_config.mode = mime;
5  var cells = IPython.notebook.get_cells();
6  for (i = 0; i < cells.length; i++) {
7  var cell = cells[i];
8  if (cell.cell_type == "code") {
9  cell.code_mirror.setOption('mode', mime);
10  cell.cm_config.mode = mime;
11  }
12  }
13 }
14 
15 // Configure C++ syntax highlighting for magics and C++-only notebooks
16 require(['base/js/namespace', 'base/js/events', 'codemirror/mode/clike/clike'],
17  function(IPython, events, clike) {
18  var cppMIME = 'text/x-c++src';
19  events.on("kernel_ready.Kernel", function() {
20  var kernel_name = IPython.notebook.kernel.name;
21  if (kernel_name == "ipyroot") {
22  IPython.CodeCell.config_defaults.highlight_modes['magic_' + cppMIME] = {'reg':[/^%%cpp|^%%dcl/]};
23  console.log("ROOTaaS - C++ magics highlighting configured");
24  }
25  else if (kernel_name == "root") {
26  highlight_cells(IPython, cppMIME);
27  $('body').one('keydown.wysiwyg', function() {
28  highlight_cells(IPython, cppMIME);
29  });
30  events.one("edit_mode.Notebook", function() {
31  highlight_cells(IPython, cppMIME);
32  });
33  console.log("ROOTaaS - C++ highlighting ON");
34  }
35  });
36  });
37 
38 // Terminal button
39 $(document).ready(function() {
40  if (document.title == "Home") {
41  $('div#header-container').append("<a href='terminals/1' class='btn btn-default btn-sm navbar-btn pull-right' style='margin-right: 4px; margin-left: 2px;'>Terminal</a>");
42  }
43 });
highlight_cells
Definition: custom.js:3
document ready(function(){if(document.title=="Home"){$('div#header-container').append("<a href='terminals/1' class='btn btn-default btn-sm navbar-btn pull-right' style='margin-right: 4px; margin-left: 2px;'>Terminal</a>");}})