2020-05-25 21:30:55 -05:00
|
|
|
import React from "react";
|
|
|
|
import * as ReactDOM from "react-dom";
|
|
|
|
import "bootstrap/dist/css/bootstrap.css";
|
2020-06-05 04:04:15 +02:00
|
|
|
import { NotebookMetadata } from "../Contracts/DataModels";
|
|
|
|
import { NotebookViewerComponent } from "../Explorer/Controls/NotebookViewer/NotebookViewerComponent";
|
|
|
|
import { SessionStorageUtility, StorageKey } from "../Shared/StorageUtility";
|
2020-05-25 21:30:55 -05:00
|
|
|
|
|
|
|
const getNotebookUrl = (): string => {
|
|
|
|
const regex: RegExp = new RegExp("[?&]notebookurl=([^&#]*)|&|#|$");
|
|
|
|
const results: RegExpExecArray | null = regex.exec(window.location.href);
|
|
|
|
if (!results || !results[1]) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
return decodeURIComponent(results[1]);
|
|
|
|
};
|
|
|
|
|
|
|
|
const onInit = async () => {
|
|
|
|
var notebookMetadata: NotebookMetadata;
|
|
|
|
const notebookMetadataString = SessionStorageUtility.getEntryString(StorageKey.NotebookMetadata);
|
|
|
|
const notebookName = SessionStorageUtility.getEntryString(StorageKey.NotebookName);
|
|
|
|
|
|
|
|
if (notebookMetadataString == "null" || notebookMetadataString != null) {
|
|
|
|
notebookMetadata = (await JSON.parse(notebookMetadataString)) as NotebookMetadata;
|
|
|
|
SessionStorageUtility.removeEntry(StorageKey.NotebookMetadata);
|
|
|
|
SessionStorageUtility.removeEntry(StorageKey.NotebookName);
|
|
|
|
}
|
|
|
|
|
2020-06-05 04:04:15 +02:00
|
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
|
|
|
2020-05-25 21:30:55 -05:00
|
|
|
const notebookViewerComponent = (
|
|
|
|
<NotebookViewerComponent
|
|
|
|
notebookMetadata={notebookMetadata}
|
|
|
|
notebookName={notebookName}
|
|
|
|
notebookUrl={getNotebookUrl()}
|
2020-06-05 04:04:15 +02:00
|
|
|
hideInputs={urlParams.get("hideinputs") === "true"}
|
2020-05-25 21:30:55 -05:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
ReactDOM.render(notebookViewerComponent, document.getElementById("notebookContent"));
|
|
|
|
};
|
|
|
|
|
|
|
|
// Entry point
|
|
|
|
window.addEventListener("load", onInit);
|