').appendTo(this.wrap);
return this.termArea;
}
@@ -166,13 +168,14 @@ TerminalClient.prototype.close = function() {
if (this.closed) {
return;
}
+ this.closed = true;
console.log('Closing notebook_xterm.');
clearTimeout(this.termPollTimer);
this.server_exec(PY_XTERM_INSTANCE + '.deleteTerminalServer()');
- this.closed = true;
+ $("#" + this.div_id).remove()
}
// create the TerminalClient instance (only once!)
if (window.terminalClient) {
+ window.terminalClient.close()
delete window.terminalClient;
-}
-window.terminalClient = new TerminalClient($('#notebook_xterm'))
+}
\ No newline at end of file
diff --git a/notebook_xterm/xterm.py b/notebook_xterm/xterm.py
index d7153a7..8080add 100644
--- a/notebook_xterm/xterm.py
+++ b/notebook_xterm/xterm.py
@@ -5,6 +5,8 @@
from .terminalserver import TerminalServer
from IPython.core.display import display, HTML
from IPython.core.magic import (Magics, magics_class, line_magic, cell_magic)
+from base64 import b64encode
+from uuid import uuid4
JS_FILE_NAME = 'terminalclient.js'
@@ -17,11 +19,18 @@ def xterm(self, line):
with open(jsPath) as f:
terminalClient_js = f.read()
- markup = """
-
-
- """.format(terminalClient_js)
+ unique_id = str(uuid4())
+ markup = f"""
+
+
+ """
display(HTML(markup))
+ ts = self.getTerminalServer()
+
+ return self.getTerminalServer()
def getTerminalServer(self):
try: