From b4d7eb17731f8fcf7a10baa9200832850433d811 Mon Sep 17 00:00:00 2001 From: Lars Windolf Date: Thu, 7 Sep 2023 00:04:03 +0200 Subject: [PATCH] Rename notebook extension --- frontend/index.html | 1 + frontend/js/notebook.js | 15 ++++++++++++--- frontend/worker.js | 7 ++++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/frontend/index.html b/frontend/index.html index 4d792ca..2c24acd 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -57,6 +57,7 @@ diff --git a/frontend/js/notebook.js b/frontend/js/notebook.js index 3a9454f..247d91b 100644 --- a/frontend/js/notebook.js +++ b/frontend/js/notebook.js @@ -76,11 +76,9 @@ function registerStarboardShellCellType() { } } - runtime.definitions.cellTypes.map.delete('esm'); runtime.definitions.cellTypes.map.delete('js'); runtime.definitions.cellTypes.map.delete('javascript'); runtime.definitions.cellTypes.map.delete('css'); - runtime.definitions.cellTypes.map.delete('html'); runtime.definitions.cellTypes.map.delete('python'); runtime.definitions.cellTypes.map.delete('python3'); runtime.definitions.cellTypes.map.delete('ipython3'); @@ -107,7 +105,7 @@ async function setupNotebook(host, name) { $('#notebook-name').val(name); $('#notebook-host').val(host); - let response = await fetch(`/notebooks/${name}.md`); + let response = await fetch(`/notebooks/${name}.nb`); window.initialNotebookContent = await response.text(); /* Async module load to ensure we have loaded the initial notebook markdown above */ @@ -118,4 +116,15 @@ async function setupNotebook(host, name) { $('#notebook-host').on('change', reloadNotebook); } +// Helper function to allow JS notebook cells to get output of other cells +window.getCellOutput = (cellNr) => { + if(undefined === runtime.content.cells[cellNr]) { + console.error(`No cell with index ${cellNr} found!`); + return ""; + } + + let id = runtime.content.cells[cellNr].id; + return $(`starboard-cell#${id} .starboard-console-output-inner`).get(0).innerText; +}; + export { setupNotebook }; \ No newline at end of file diff --git a/frontend/worker.js b/frontend/worker.js index 12f1b26..a2dab5e 100644 --- a/frontend/worker.js +++ b/frontend/worker.js @@ -26,9 +26,10 @@ var filesToCache = [ '/js/renderer/netmap.js', '/js/renderer/perf-flamegraph.js', - '/notebooks/default.md', - '/notebooks/arp.md', - '/notebooks/systemd.md', + '/notebooks/default.nb', + '/notebooks/df.nb', + '/notebooks/arp.nb', + '/notebooks/systemd.nb', 'default.json' ];