Skip to content

Instantly share code, notes, and snippets.

@steveosoule
Created November 29, 2018 02:13
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 steveosoule/592058c999b1b635f2e5c30bbfb423a5 to your computer and use it in GitHub Desktop.
Save steveosoule/592058c999b1b635f2e5c30bbfb423a5 to your computer and use it in GitHub Desktop.
Pixiedust Python Nodebook
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Pixiedust database opened successfully\n",
"Table VERSION_TRACKER created successfully\n",
"Table METRICS_TRACKER created successfully\n",
"\n",
"Share anonymous install statistics? (opt-out instructions)\n",
"\n",
"PixieDust will record metadata on its environment the next time the package is installed or updated. The data is anonymized and aggregated to help plan for future releases, and records only the following values:\n",
"\n",
"{\n",
" \"data_sent\": currentDate,\n",
" \"runtime\": \"python\",\n",
" \"application_version\": currentPixiedustVersion,\n",
" \"space_id\": nonIdentifyingUniqueId,\n",
" \"config\": {\n",
" \"repository_id\": \"https://github.com/ibm-watson-data-lab/pixiedust\",\n",
" \"target_runtimes\": [\"Data Science Experience\"],\n",
" \"event_id\": \"web\",\n",
" \"event_organizer\": \"dev-journeys\"\n",
" }\n",
"}\n",
"You can opt out by calling pixiedust.optOut() in a new cell.\n"
]
},
{
"data": {
"text/html": [
"\n",
" <div style=\"margin:10px\">\n",
" <a href=\"https://github.com/ibm-watson-data-lab/pixiedust\" target=\"_new\">\n",
" <img src=\"https://github.com/ibm-watson-data-lab/pixiedust/raw/master/docs/_static/pd_icon32.png\" style=\"float:left;margin-right:10px\"/>\n",
" </a>\n",
" <span>Pixiedust version 1.1.14</span>\n",
" </div>\n",
" "
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Pixiedust runtime updated. Please restart kernel\n",
"Table USER_PREFERENCES created successfully\n",
"Table service_connections created successfully\n"
]
},
{
"data": {
"text/html": [
"\n",
" <div style=\"margin:10px\"> \n",
" <a href=\"https://github.com/ibm-cds-labs/pixiedust_node\" target=\"_new\"> \n",
" <img src=\"https://github.com/ibm-cds-labs/pixiedust_node/raw/master/docs/_images/pdn_icon32.png\" style=\"float:left;margin-right:10px\"/> \n",
" </a> \n",
" <span>Pixiedust Node.js</span> \n",
" </div> \n"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# https://medium.com/ibm-watson-data-lab/nodebooks-node-js-data-science-notebooks-aa140bea21ba\n",
"import pixiedust_node"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"pixiedust_node 0.2.5 started. Cells starting '%%node' may contain Node.js code.\n",
"\"2018-11-29T02:10:33.613Z\"\n"
]
}
],
"source": [
"%%node\n",
"var date = new Date();\n",
"print(date);"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\"a\": 1, \"b\": \"two\", \"c\": true}\n"
]
}
],
"source": [
"%%node\n",
"var x = { a:1, b:'two', c: true };\n",
"print(x);\n",
"// {\"a\": 1, \"b\": \"two\", \"c\": true}"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"... ... ..... ..... ..... ..... ..... ..... ... ...\n"
]
},
{
"data": {
"application/javascript": [
"if (typeof pixiedust == \"undefined\"){\n",
" var s=document.getElementsByTagName('script')[0];\n",
" var g=document.createElement( 'style' );\n",
" g.type='text/css';\n",
" g.defer=false; \n",
" g.async=false;\n",
" var code = \"pd_script,pd_dialog,pd_options,pd_target,pd_event_payload{\\n\"+\n",
"\" display:none\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\".output_subarea.rendered_html {\\n\"+\n",
"\" max-width: 100%;\\n\"+\n",
"\" padding: 0;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust {\\n\"+\n",
"\" border: 1px solid #ececec;\\n\"+\n",
"\" border-radius: 3px;\\n\"+\n",
"\" margin: 10px 0;\\n\"+\n",
"\" padding: 10px;\\n\"+\n",
"\"\\n\"+\n",
"\" color: #333333;\\n\"+\n",
"\" font-size: small;\\n\"+\n",
"\" font-weight: 300;\\n\"+\n",
"\" letter-spacing: 0.5px;\\n\"+\n",
"\" line-height: normal;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .btn-group {\\n\"+\n",
"\" border-right: 0;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .display-type-button:not(:first-child) {\\n\"+\n",
"\" margin-left: 10px !important;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .btn-default {\\n\"+\n",
"\" border-radius: 0;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust-toolbar .btn-default.focus,\\n\"+\n",
"\".pixiedust-toolbar .btn-default:focus,\\n\"+\n",
"\".pixiedust-toolbar .btn-default:hover,\\n\"+\n",
"\".pixiedust .chart-button-group .btn-default.focus,\\n\"+\n",
"\".pixiedust .chart-button-group .btn-default:focus,\\n\"+\n",
"\".pixiedust .chart-button-group .btn-default:hover {\\n\"+\n",
"\" background-color: #337ab7;\\n\"+\n",
"\" border-color: #2e6da4;\\n\"+\n",
"\" color: #ffffff;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .dropdown-menu {\\n\"+\n",
"\" background-color: #ffffff;\\n\"+\n",
"\" border-color: rgba(0, 0, 0, 0.15);\\n\"+\n",
"\" padding: 0;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .dropdown-menu ul {\\n\"+\n",
"\" list-style: outside none none;\\n\"+\n",
"\" margin: 0;\\n\"+\n",
"\" padding: 0;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .dropdown-menu li {\\n\"+\n",
"\" cursor: pointer;\\n\"+\n",
"\" padding: 8px 12px;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .dropdown-menu li:hover {\\n\"+\n",
"\" background-color: #337ab7;\\n\"+\n",
"\" color: #ffffff;\\n\"+\n",
"\" cursor: pointer;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .dropdown-menu li > span {\\n\"+\n",
"\" display: inline-block;\\n\"+\n",
"\" margin-left: 10px;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .btn .fa-chevron-down {\\n\"+\n",
"\" margin-left: 25px;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .btn-group.open .dropdown-toggle {\\n\"+\n",
"\" background-color: #337ab7;\\n\"+\n",
"\" border-color: #2e6da4;\\n\"+\n",
"\" color: #ffffff;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .modal-dialog {\\n\"+\n",
"\" width: 50vw;\\n\"+\n",
"\" min-width: 700px;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .modal-dialog .btn-default:focus,\\n\"+\n",
"\".pixiedust .modal-dialog .btn-default:hover {\\n\"+\n",
"\" background-color: #e6e6e6;\\n\"+\n",
"\" border-color: #adadad;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .modal-dialog .btn-primary {\\n\"+\n",
"\" background-color: #337ab7;\\n\"+\n",
"\" color: #fff;\\n\"+\n",
"\" transition: background-color 0.15s ease-out 0s;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .modal-dialog .btn-primary:focus,\\n\"+\n",
"\".pixiedust .modal-dialog .btn-primary:hover {\\n\"+\n",
"\" background-color: #286090;\\n\"+\n",
"\" border-color: #204d74;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .modal-header {\\n\"+\n",
"\" background-color: #337ab7;\\n\"+\n",
"\" color: #ffffff;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .modal-header .close {\\n\"+\n",
"\" color: #fff;\\n\"+\n",
"\" opacity: 1;\\n\"+\n",
"\" text-shadow: none;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .modal-header .close:hover {\\n\"+\n",
"\" opacity: 0.5;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .modal-body {\\n\"+\n",
"\" padding: 25px;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .modal-footer .btn {\\n\"+\n",
"\" min-width: 75px;\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\".pixiedust .executionTime {\\n\"+\n",
"\" color: gray;\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\".pixiedust .expandButton {\\n\"+\n",
"\" background-color: transparent;\\n\"+\n",
"\" border: 0 none;\\n\"+\n",
"\" font-size: 15px;\\n\"+\n",
"\" padding: 0;\\n\"+\n",
"\" position: relative;\\n\"+\n",
"\" right: 0;\\n\"+\n",
"\" text-align: right;\\n\"+\n",
"\" top: 0;\\n\"+\n",
"\" width: 100%;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .expandButton:hover,\\n\"+\n",
"\".pixiedust .expandButton:active,\\n\"+\n",
"\".pixiedust .expandButton:focus {\\n\"+\n",
"\" background-color: transparent;\\n\"+\n",
"\" color: #337ab7;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .expandButton:not(.collapsed) {\\n\"+\n",
"\" float: right;\\n\"+\n",
"\" width: initial;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .expandButton > i.fa:before {\\n\"+\n",
"\" content: \\\"\\\\f066\\\";\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .expandButton.collapsed > i.fa:before {\\n\"+\n",
"\" content: \\\"\\\\f065\\\";\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .expandButton.collapsed:before {\\n\"+\n",
"\" color: #999999;\\n\"+\n",
"\" content: \\\"Pixiedust output minimized\\\";\\n\"+\n",
"\" float: left;\\n\"+\n",
"\" font-size: 14px;\\n\"+\n",
"\" font-style: italic;\\n\"+\n",
"\" font-weight: 300;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .chart-button-group {\\n\"+\n",
"\" border-bottom: 1px solid #ececec;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .rendererOpt {\\n\"+\n",
"\" margin: 6px 0;\\n\"+\n",
"\" padding: 6px 0;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .rendererOpt:first-child {\\n\"+\n",
"\" margin-top: 0;\\n\"+\n",
"\" padding-top: 0;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .rendererOpt.checkbox { padding-left: 20px; }\\n\"+\n",
"\".pixiedust .rendererOpt.checkbox label {\\n\"+\n",
"\" display: inline-block;\\n\"+\n",
"\" position: relative;\\n\"+\n",
"\" padding-left: 5px;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .rendererOpt.checkbox label::before {\\n\"+\n",
"\" content: \\\"\\\";\\n\"+\n",
"\" display: inline-block;\\n\"+\n",
"\" position: absolute;\\n\"+\n",
"\" width: 17px;\\n\"+\n",
"\" height: 17px;\\n\"+\n",
"\" left: 0;\\n\"+\n",
"\" margin-left: -20px;\\n\"+\n",
"\" border: 1px solid #cccccc;\\n\"+\n",
"\" background-color: #fff;\\n\"+\n",
"\" -webkit-transition: border 0.15s ease-in-out, color 0.15s ease-in-out;\\n\"+\n",
"\" -o-transition: border 0.15s ease-in-out, color 0.15s ease-in-out;\\n\"+\n",
"\" transition: border 0.15s ease-in-out, color 0.15s ease-in-out;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .rendererOpt.checkbox label::after {\\n\"+\n",
"\" display: inline-block;\\n\"+\n",
"\" position: absolute;\\n\"+\n",
"\" width: 16px;\\n\"+\n",
"\" height: 16px;\\n\"+\n",
"\" left: 0;\\n\"+\n",
"\" top: 0;\\n\"+\n",
"\" margin-left: -20px;\\n\"+\n",
"\" padding-left: 2px;\\n\"+\n",
"\" padding-top: 1px;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .rendererOpt.checkbox input[type=\\\"checkbox\\\"] {\\n\"+\n",
"\" opacity: 0;\\n\"+\n",
"\" z-index: 1;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .rendererOpt.checkbox input[type=\\\"checkbox\\\"]:focus + label::before {\\n\"+\n",
"\" outline: thin dotted;\\n\"+\n",
"\" outline: 5px auto -webkit-focus-ring-color;\\n\"+\n",
"\" outline-offset: -2px;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .rendererOpt.checkbox input[type=\\\"checkbox\\\"]:checked + label::after {\\n\"+\n",
"\" font-family: 'FontAwesome';\\n\"+\n",
"\" content: \\\"\\\\f00c\\\";\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\".pixiedust .rendererOpt.checkbox.checkbox-inline { margin-top: 0; }\\n\"+\n",
"\"\\n\"+\n",
"\".pixiedust .rendererOpt.checkbox-primary input[type=\\\"checkbox\\\"]:checked + label::before {\\n\"+\n",
"\" background-color: #337ab7;\\n\"+\n",
"\" border-color: #337ab7;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust .rendererOpt.checkbox-primary input[type=\\\"checkbox\\\"]:checked + label::after {\\n\"+\n",
"\" color: #fff;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust-app .modal-dialog {\\n\"+\n",
"\" width: 95% !important;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust-app .modal-dialog .pixiedust {\\n\"+\n",
"\" border: none;\\n\"+\n",
"\" height: calc(100vh - 200px);\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust-app .modal-dialog .expandButton {\\n\"+\n",
"\" visibility: hidden;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust-app .pixiedust-output-wrapper,\\n\"+\n",
"\".pixiedust-app .pixiedustWrapperHTML,\\n\"+\n",
"\".pixiedust-app [pixiedust]:not(.pixiedust) {\\n\"+\n",
"\" height: 100%;\\n\"+\n",
"\" position: relative;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust-app.pixiedust-default-dialog .modal-dialog {\\n\"+\n",
"\" max-width: 1000px !important;\\n\"+\n",
"\" min-width: 600px !important;\\n\"+\n",
"\" width: 50% !important;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust-app.pixiedust-default-dialog .modal-dialog .pixiedust {\\n\"+\n",
"\" height: auto !important;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust-app.pixiedust-maximize.modal {\\n\"+\n",
"\" border: 0 none;\\n\"+\n",
"\" margin: 0;\\n\"+\n",
"\" padding: 0 !important;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust-app.pixiedust-maximize .modal-dialog {\\n\"+\n",
"\" height: 100% !important;\\n\"+\n",
"\" margin: 0;\\n\"+\n",
"\" overflow: hidden;\\n\"+\n",
"\" padding: 0;\\n\"+\n",
"\" width: 100% !important;\\n\"+\n",
"\"}\\n\"+\n",
"\".pixiedust-app.pixiedust-maximize .modal-dialog .pixiedust {\\n\"+\n",
"\" height: calc(100vh - 88px);\\n\"+\n",
"\" padding: 0px;\\n\"+\n",
"\"}\";\n",
" try{\n",
" g.appendChild(document.createTextNode(code));\n",
" }catch(e){\n",
" g.text = code;\n",
" }\n",
" s.parentNode.insertBefore(g,s);\n",
"}"
],
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/javascript": [
"if (typeof pixiedust == \"undefined\"){\n",
" var s=document.getElementsByTagName('script')[0];\n",
" var g=document.createElement( 'script' );\n",
" g.type= 'text/javascript';\n",
" g.defer=false; \n",
" g.async=false;\n",
" var code = \"var pixiedust = (function(){\\n\"+\n",
"\" return {\\n\"+\n",
"\" input_reply_queue: {\\n\"+\n",
"\" inflight: null,\\n\"+\n",
"\" queue: [],\\n\"+\n",
"\" callbacks: {},\\n\"+\n",
"\" counter: 0,\\n\"+\n",
"\" registerCallback: function(cb){\\n\"+\n",
"\" var handle = 'id_' + this.counter++;\\n\"+\n",
"\" this.callbacks[handle] = cb;\\n\"+\n",
"\" return \\\"$$\\\" + handle + \\\"$$\\\";\\n\"+\n",
"\" },\\n\"+\n",
"\" parseCallback: function(content){\\n\"+\n",
"\" var match = content.text.match(/\\\\$\\\\$(.*)\\\\$\\\\$((.|\\\\n)*)/i);\\n\"+\n",
"\" if (match){\\n\"+\n",
"\" content.text = match[2].trim();\\n\"+\n",
"\" if (!this.callbacks[match[1]]){\\n\"+\n",
"\" console.log(\\\"Cannot find callbacks for \\\" + match[1]);\\n\"+\n",
"\" }else{\\n\"+\n",
"\" var retValue = this.callbacks[match[1]];\\n\"+\n",
"\" delete this.callbacks[match[1]];\\n\"+\n",
"\" return retValue;\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" return null;\\n\"+\n",
"\" }\\n\"+\n",
"\" },\\n\"+\n",
"\" getCell: function(cell_id){\\n\"+\n",
"\" \\n\"+\n",
"\" var cells=IPython.notebook.get_cells().filter(function(cell){\\n\"+\n",
"\" return cell.cell_id==cell_id;\\n\"+\n",
"\" });\\n\"+\n",
"\" \\n\"+\n",
"\" return cells.length>0?cells[0]:null;\\n\"+\n",
"\" },\\n\"+\n",
"\" \\n\"+\n",
"\" executeDisplay:function(pd_ctls, user_ctls){\\n\"+\n",
"\" var pd_controls = pd_ctls || {};\\n\"+\n",
"\" var user_controls = user_ctls || {\\\"options\\\":{}};\\n\"+\n",
"\" if (user_controls.inFlight){\\n\"+\n",
"\" console.log(\\\"Ignoring request to execute Display that is already being executed\\\");\\n\"+\n",
"\" return;\\n\"+\n",
"\" }\\n\"+\n",
"\" user_controls.inFlight = true;\\n\"+\n",
"\" var options = $.extend({}, pd_controls.options || {}, user_controls.options || {} );\\n\"+\n",
"\" function wrapDisplayDone(fn){\\n\"+\n",
"\" return function(targetNode, targetNodeUpdated){\\n\"+\n",
"\" user_controls.inFlight = false;\\n\"+\n",
"\" if(targetNodeUpdated){\\n\"+\n",
"\" if (fn){\\n\"+\n",
"\" fn.apply(this);\\n\"+\n",
"\" }\\n\"+\n",
"\" $(document).trigger('pd_event', {type:\\\"pd_load\\\", targetNode: targetNode});\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" user_controls.onDisplayDone = wrapDisplayDone( user_controls.onDisplayDone);\\n\"+\n",
"\" var pd_prefix = pd_controls.prefix;\\n\"+\n",
"\" var $targetDivId = user_controls.targetDivId;\\n\"+\n",
"\" !function() {\\n\"+\n",
"\" function getTargetNodeId(override=null){\\n\"+\n",
"\" return override || $targetDivId || (\\\"wrapperHTML\\\"+ pd_prefix);\\n\"+\n",
"\" }\\n\"+\n",
"\" function getTargetNode(override=null){\\n\"+\n",
"\" return $('#' + getTargetNodeId(override));\\n\"+\n",
"\" }\\n\"+\n",
"\" function checkRootInit(){\\n\"+\n",
"\" node = getTargetNode();\\n\"+\n",
"\" var retValue = node.is(\\\"[pd_init]\\\");\\n\"+\n",
"\" if (retValue){\\n\"+\n",
"\" node.removeAttr(\\\"pd_init\\\");\\n\"+\n",
"\" }\\n\"+\n",
"\" return retValue;\\n\"+\n",
"\" }\\n\"+\n",
"\" function setText(targetNode, contents, pdCtl = null, userCtl = null){\\n\"+\n",
"\" var pd_elements = []\\n\"+\n",
"\" targetNode.children().each(function(){\\n\"+\n",
"\" if (this.tagName.toLowerCase().startsWith(\\\"pd_\\\")){\\n\"+\n",
"\" pd_elements.push($(this).clone());\\n\"+\n",
"\" }\\n\"+\n",
"\" });\\n\"+\n",
"\" if (!targetNode.hasClass(\\\"use_stream_output\\\")){\\n\"+\n",
"\" targetNode.text(contents);\\n\"+\n",
"\" }else{\\n\"+\n",
"\" var consoleNode = targetNode.children(\\\"div.consoleOutput\\\");\\n\"+\n",
"\" if (consoleNode.length == 0){\\n\"+\n",
"\" consoleNode = targetNode.append('<div class=\\\"consoleOutput\\\"></div>').children(\\\"div.consoleOutput\\\");\\n\"+\n",
"\" }\\n\"+\n",
"\" var existing = consoleNode.text();\\n\"+\n",
"\" if (existing != \\\"\\\"){\\n\"+\n",
"\" contents = existing + \\\"\\\\n\\\" + contents;\\n\"+\n",
"\" }\\n\"+\n",
"\" consoleNode.html('<pre style=\\\"max-height: 300px;border: 1px lightgray solid;margin-top: 20px;\\\">' + contents + \\\"</pre>\\\");\\n\"+\n",
"\" }\\n\"+\n",
"\" if (pd_elements.length > 0 ){\\n\"+\n",
"\" targetNode.append(pd_elements);\\n\"+\n",
"\" }\\n\"+\n",
"\" return true;\\n\"+\n",
"\" }\\n\"+\n",
"\" function setHTML(targetNode, contents, pdCtl = null, userCtl = null){\\n\"+\n",
"\" var pd_elements = []\\n\"+\n",
"\" targetNode.children().each(function(){\\n\"+\n",
"\" var eltName = this.tagName.toLowerCase();\\n\"+\n",
"\" if (eltName.startsWith(\\\"pd_\\\") || (eltName == \\\"div\\\" && this.classList.contains(\\\"consoleOutput\\\")) ){\\n\"+\n",
"\" pd_elements.push($(this).clone());\\n\"+\n",
"\" }\\n\"+\n",
"\" });\\n\"+\n",
"\" targetNode.html(\\\"<div pd_stop_propagation style='height:100%;'>\\\" + contents + \\\"</div>\\\");\\n\"+\n",
"\" if (pd_elements.length > 0 ){\\n\"+\n",
"\" targetNode.append(pd_elements);\\n\"+\n",
"\" }\\n\"+\n",
"\" return true;\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" function send_input_reply(cb, cmd, pd_controls){\\n\"+\n",
"\" if (cmd == 'c' || cmd == 'continue' || cmd == 'q' || cmd == 'quit' || cmd.startsWith(\\\"$$\\\")){\\n\"+\n",
"\" cb = null;\\n\"+\n",
"\" pixiedust.input_reply_queue.queue = [];\\n\"+\n",
"\" pixiedust.input_reply_queue.callbacks = {};\\n\"+\n",
"\" $(\\\"#debugger_container_\\\" + pd_controls.prefix).hide();\\n\"+\n",
"\" if (cmd.startsWith(\\\"$$\\\")){\\n\"+\n",
"\" cmd = cmd.substring(2);\\n\"+\n",
"\" }\\n\"+\n",
"\" }else if (cmd == 'no_op'){\\n\"+\n",
"\" cb = null;\\n\"+\n",
"\" cmd = null;\\n\"+\n",
"\" }\\n\"+\n",
"\" if (cb && $targetDivId == \\\"debugger_refresh\\\"){\\n\"+\n",
"\" cb.refreshDebugger = true;\\n\"+\n",
"\" }\\n\"+\n",
"\" pixiedust.input_reply_queue.inflight = cb;\\n\"+\n",
"\" if (cmd){\\n\"+\n",
"\" var prolog = cb ? \\\"print('\\\" + pixiedust.input_reply_queue.registerCallback(cb) + \\\"');;\\\" : \\\"\\\";\\n\"+\n",
"\" IPython.notebook.session.kernel.send_input_reply( prolog + cmd );\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" var cellId = options.cell_id || \\\"\\\";\\n\"+\n",
"\" var curCell = pixiedust.getCell(cellId);\\n\"+\n",
"\" console.log(\\\"curCell\\\",curCell);\\n\"+\n",
"\" \\n\"+\n",
"\" var callbacks = {\\n\"+\n",
"\" shell : {\\n\"+\n",
"\" reply : function(){\\n\"+\n",
"\" if ( !callbacks.response ){\\n\"+\n",
"\" var targetNodeUpdated = false;\\n\"+\n",
"\" if (!user_controls.partialUpdate){\\n\"+\n",
"\" targetNodeUpdated = setHTML(getTargetNode(), \\\"\\\",pd_controls, user_controls);\\n\"+\n",
"\" }\\n\"+\n",
"\" if (user_controls.onDisplayDone){\\n\"+\n",
"\" user_controls.onDisplayDone(getTargetNode(), targetNodeUpdated);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" },\\n\"+\n",
"\" payload : {\\n\"+\n",
"\" set_next_input : function(payload){\\n\"+\n",
"\" if (curCell){\\n\"+\n",
"\" curCell._handle_set_next_input(payload);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" },\\n\"+\n",
"\" iopub:{\\n\"+\n",
"\" output:function(msg){\\n\"+\n",
"\" if (curCell && !$targetDivId && getTargetNode().length == 0){\\n\"+\n",
"\" curCell.output_area.handle_output.apply(curCell.output_area, arguments);\\n\"+\n",
"\" return;\\n\"+\n",
"\" }\\n\"+\n",
"\" callbacks.response = true;\\n\"+\n",
"\" console.log(\\\"msg\\\", msg);\\n\"+\n",
"\" \\n\"+\n",
"\" if (cellId == \\\"\\\"){\\n\"+\n",
"\" if (curCell){\\n\"+\n",
"\" curCell.output_area.handle_output.apply(curCell.output_area, arguments);\\n\"+\n",
"\" curCell.output_area.outputs=[];\\n\"+\n",
"\" }else{\\n\"+\n",
"\" console.log(\\\"Could not find current cell\\\");\\n\"+\n",
"\" }\\n\"+\n",
"\" return;\\n\"+\n",
"\" }\\n\"+\n",
"\" \\n\"+\n",
"\" var msg_type=msg.header.msg_type;\\n\"+\n",
"\" var content = msg.content;\\n\"+\n",
"\" var targetNodeUpdated = false;\\n\"+\n",
"\" if(msg_type===\\\"stream\\\"){\\n\"+\n",
"\" var reply_callbacks = pixiedust.input_reply_queue.parseCallback(content);\\n\"+\n",
"\" if (reply_callbacks && reply_callbacks != callbacks){\\n\"+\n",
"\" if (reply_callbacks.iopub){\\n\"+\n",
"\" reply_callbacks.iopub.output(msg);\\n\"+\n",
"\" }\\n\"+\n",
"\" return;\\n\"+\n",
"\" }\\n\"+\n",
"\" var useHTML = false;\\n\"+\n",
"\" var process_output = getScriptOfType($(\\\"#\\\" + $targetDivId), \\\"process_output\\\");\\n\"+\n",
"\" if (process_output){\\n\"+\n",
"\" try{\\n\"+\n",
"\" content.text = new Function('output', process_output)(content.text);\\n\"+\n",
"\" useHTML = true;\\n\"+\n",
"\" }catch(e){\\n\"+\n",
"\" console.log(\\\"Error while invoking post output function\\\", e, content.text, process_output);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" if (user_controls.onSuccess){\\n\"+\n",
"\" user_controls.onSuccess(content.text);\\n\"+\n",
"\" }else{\\n\"+\n",
"\" fn = useHTML?setHTML:setText;\\n\"+\n",
"\" targetNodeUpdated = fn(getTargetNode(), content.text, pd_controls, user_controls);\\n\"+\n",
"\" }\\n\"+\n",
"\" }else if (msg_type===\\\"display_data\\\" || msg_type===\\\"execute_result\\\"){\\n\"+\n",
"\" var html=null;\\n\"+\n",
"\" if (!!content.data[\\\"text/html\\\"]){\\n\"+\n",
"\" html=content.data[\\\"text/html\\\"];\\n\"+\n",
"\" }else if (!!content.data[\\\"image/png\\\"]){\\n\"+\n",
"\" html=html||\\\"\\\";\\n\"+\n",
"\" html+=\\\"<img src='data:image/png;base64,\\\" +content.data[\\\"image/png\\\"]+\\\"'></img>\\\";\\n\"+\n",
"\" }\\n\"+\n",
"\" \\n\"+\n",
"\" if (!!content.data[\\\"application/javascript\\\"]){\\n\"+\n",
"\" try {\\n\"+\n",
"\" eval(content.data[\\\"application/javascript\\\"]);\\n\"+\n",
"\" } catch(err) {\\n\"+\n",
"\" curCell.output_area.handle_output.apply(curCell.output_area, arguments);\\n\"+\n",
"\" } \\n\"+\n",
"\" return;\\n\"+\n",
"\" }\\n\"+\n",
"\" \\n\"+\n",
"\" if (html){\\n\"+\n",
"\" try{\\n\"+\n",
"\" if (user_controls.onSuccess){\\n\"+\n",
"\" user_controls.onSuccess(html);\\n\"+\n",
"\" }else{\\n\"+\n",
"\" targetNodeUpdated = setHTML(getTargetNode(), html, pd_controls, user_controls);\\n\"+\n",
"\" }\\n\"+\n",
"\" if (content.metadata && content.metadata.pixieapp_metadata){\\n\"+\n",
"\" \\n\"+\n",
"\" if (curCell){\\n\"+\n",
"\" curCell._metadata.pixiedust.pixieapp = content.metadata.pixieapp_metadata;\\n\"+\n",
"\" }\\n\"+\n",
"\" \\n\"+\n",
"\" } \\n\"+\n",
"\" }catch(e){\\n\"+\n",
"\" console.log(\\\"Invalid html output\\\", e, html);\\n\"+\n",
"\" targetNodeUpdated = setHTML(getTargetNode(), \\\"Invalid html output: \\\" + e.message + \\\"<pre>\\\" \\n\"+\n",
"\" + html.replace(/>/g,'&gt;').replace(/</g,'&lt;').replace(/\\\"/g,'&quot;') + \\\"<pre>\\\",\\n\"+\n",
"\" pd_controls, user_controls);\\n\"+\n",
"\" }\\n\"+\n",
"\" if (callbacks.options && callbacks.options.nostore_delaysave){\\n\"+\n",
"\" setTimeout(function(){\\n\"+\n",
"\" pixiedust.saveOutputInCell(curCell, content, html, msg_type);\\n\"+\n",
"\" }, 1000);\\n\"+\n",
"\" }else{\\n\"+\n",
"\" pixiedust.saveOutputInCell(curCell, content, html, msg_type);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" }else if (msg_type === \\\"error\\\") {\\n\"+\n",
"\" \\n\"+\n",
"\" require(['base/js/utils'], function(utils) {\\n\"+\n",
"\" if (content.ename == \\\"BdbQuit\\\"){\\n\"+\n",
"\" targetNodeUpdated = setHTML(\\n\"+\n",
"\" getTargetNode(), \\n\"+\n",
"\" \\\"PixieDebugger exited\\\", \\n\"+\n",
"\" pd_controls, \\n\"+\n",
"\" user_controls\\n\"+\n",
"\" );\\n\"+\n",
"\" }else{\\n\"+\n",
"\" var tb = content.traceback;\\n\"+\n",
"\" console.log(\\\"tb\\\",tb);\\n\"+\n",
"\" if (tb && tb.length>0){\\n\"+\n",
"\" var data = tb.reduce(function(res, frame){return res+frame+'\\\\\\\\n';},\\\"\\\");\\n\"+\n",
"\" console.log(\\\"data\\\",data);\\n\"+\n",
"\" data = utils.fixConsole(data);\\n\"+\n",
"\" data = utils.fixCarriageReturn(data);\\n\"+\n",
"\" data = utils.autoLinkUrls(data);\\n\"+\n",
"\" if (user_controls.onError){\\n\"+\n",
"\" user_controls.onError(data);\\n\"+\n",
"\" }else{\\n\"+\n",
"\" var debugger_html = '<button type=\\\"submit\\\" pd_options=\\\"new_parent_prefix=false\\\" pd_target=\\\"' + \\n\"+\n",
"\" getTargetNodeId() + '\\\" pd_app=\\\"pixiedust.apps.debugger.PixieDebugger\\\">Post Mortem</button>' +\\n\"+\n",
"\" '<span>&nbsp;&nbsp;</span>' +\\n\"+\n",
"\" '<button type=\\\"submit\\\" pd_options=\\\"new_parent_prefix=false;debug_route=true\\\" pd_target=\\\"' + \\n\"+\n",
"\" getTargetNodeId() + '\\\" pd_app=\\\"pixiedust.apps.debugger.PixieDebugger\\\">Debug Route</button>'\\n\"+\n",
"\"\\n\"+\n",
"\" targetNodeUpdated = setHTML(\\n\"+\n",
"\" getTargetNode(), \\n\"+\n",
"\" debugger_html + \\\"<pre>\\\" + data + '</pre>' + debugger_html, \\n\"+\n",
"\" pd_controls, \\n\"+\n",
"\" user_controls\\n\"+\n",
"\" );\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" });\\n\"+\n",
"\" \\n\"+\n",
"\" }else{\\n\"+\n",
"\" callbacks.response = false;\\n\"+\n",
"\" }\\n\"+\n",
"\" if (user_controls.onDisplayDone){\\n\"+\n",
"\" user_controls.onDisplayDone(getTargetNode(), targetNodeUpdated);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" },\\n\"+\n",
"\" input : function(msg){\\n\"+\n",
"\" var reply_callbacks = pixiedust.input_reply_queue.inflight;\\n\"+\n",
"\" if (!reply_callbacks || reply_callbacks.refreshDebugger){\\n\"+\n",
"\" $(\\\"#debugger_container_\\\" + pd_controls.prefix).show();\\n\"+\n",
"\" var input_target = \\\"input_reply_\\\" + pd_controls.prefix;\\n\"+\n",
"\" var process_output = getScriptOfType($(\\\"#\\\" + input_target), \\\"process_output\\\");\\n\"+\n",
"\" if (process_output){\\n\"+\n",
"\" try{\\n\"+\n",
"\" if (reply_callbacks){\\n\"+\n",
"\" reply_callbacks.refreshDebugger = false;\\n\"+\n",
"\" }\\n\"+\n",
"\" if (!pixiedust.input_reply_queue.inflight){\\n\"+\n",
"\" pixiedust.input_reply_queue.inflight = {};\\n\"+\n",
"\" }\\n\"+\n",
"\" msg.content.prompt = new Function('output', process_output)(msg.content.prompt);\\n\"+\n",
"\" targetNodeUpdated = setHTML(getTargetNode(input_target), msg.content.prompt, pd_controls, user_controls);\\n\"+\n",
"\" if (user_controls.onDisplayDone){\\n\"+\n",
"\" user_controls.onDisplayDone(getTargetNode(input_target), targetNodeUpdated);\\n\"+\n",
"\" }\\n\"+\n",
"\" }catch(e){\\n\"+\n",
"\" console.log(\\\"Error while invoking post output function\\\", e, msg.content.prompt, process_output);\\n\"+\n",
"\" }\\n\"+\n",
"\" }else{\\n\"+\n",
"\" console.log(\\\"No element with id input_reply_\\\"+pd_controls.prefix + \\\" found\\\");\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" if (reply_callbacks && reply_callbacks.answer_input_reply){\\n\"+\n",
"\" var answer = reply_callbacks.answer_input_reply;\\n\"+\n",
"\" reply_callbacks.answer_input_reply = null;\\n\"+\n",
"\" send_input_reply(reply_callbacks, answer, pd_controls);\\n\"+\n",
"\" }else{\\n\"+\n",
"\" var next_input_reply = pixiedust.input_reply_queue.queue.shift();\\n\"+\n",
"\" if (next_input_reply && next_input_reply.command == \\\"no_op_delay\\\"){\\n\"+\n",
"\" next_input_reply = pixiedust.input_reply_queue.queue.shift();\\n\"+\n",
"\" }\\n\"+\n",
"\" if (next_input_reply){\\n\"+\n",
"\" send_input_reply(next_input_reply.callbacks, next_input_reply.command, pd_controls);\\n\"+\n",
"\" }else{\\n\"+\n",
"\" pixiedust.input_reply_queue.inflight = null;\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" console.log(\\\"Handling input msg request: \\\", msg);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" \\n\"+\n",
"\" if (IPython && IPython.notebook && IPython.notebook.session && IPython.notebook.session.kernel){\\n\"+\n",
"\" \\n\"+\n",
"\" var command = user_controls.script || pd_controls.command.replace(\\\"cellId\\\",cellId);\\n\"+\n",
"\" if ( !user_controls.script){\\n\"+\n",
"\" function addOptions(options, override=true, ignoreKeys=[]){\\n\"+\n",
"\" function getStringRep(v) {\\n\"+\n",
"\" return \\\"'\\\" + v + \\\"'\\\";\\n\"+\n",
"\" }\\n\"+\n",
"\" for (var key in (options||{})){\\n\"+\n",
"\" if (ignoreKeys.indexOf(key)>=0){\\n\"+\n",
"\" continue;\\n\"+\n",
"\" }\\n\"+\n",
"\" var value = options[key];\\n\"+\n",
"\" var hasValue = value != null && typeof value !== 'undefined' && value !== '';\\n\"+\n",
"\" var replaceValue = hasValue ? (key+\\\"=\\\" + getStringRep(value) ) : \\\"\\\";\\n\"+\n",
"\" var pattern = (hasValue?\\\"\\\":\\\",\\\")+\\\"\\\\\\\\s*\\\" + key + \\\"\\\\\\\\s*=\\\\\\\\s*'(\\\\\\\\\\\\\\\\'|[^'])*'\\\";\\n\"+\n",
"\" var rpattern=new RegExp(pattern);\\n\"+\n",
"\" var n = command.search(rpattern);\\n\"+\n",
"\" if ( n >= 0 ){\\n\"+\n",
"\" if (override){\\n\"+\n",
"\" command = command.replace(rpattern, replaceValue);\\n\"+\n",
"\" }\\n\"+\n",
"\" }else if (hasValue){\\n\"+\n",
"\" var n = command.lastIndexOf(\\\")\\\");\\n\"+\n",
"\" command = [command.slice(0, n), (command[n-1]==\\\"(\\\"? \\\"\\\":\\\",\\\") + replaceValue, command.slice(n)].join('')\\n\"+\n",
"\" } \\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" if(typeof cellMetadata != \\\"undefined\\\" && cellMetadata.displayParams){\\n\"+\n",
"\" addOptions(cellMetadata.displayParams);\\n\"+\n",
"\" addOptions({\\\"showchrome\\\":\\\"true\\\"});\\n\"+\n",
"\" }else if (curCell && curCell._metadata.pixiedust ){\\n\"+\n",
"\" if (!pd_controls.avoidMetadata){\\n\"+\n",
"\" ignoreKeys = pd_controls.options.nostore_pixieapp?[\\\"handlerId\\\"]:[];\\n\"+\n",
"\" if (pd_controls.override_keys){\\n\"+\n",
"\" Array.prototype.push.apply(ignoreKeys,pd_controls.override_keys);\\n\"+\n",
"\" }\\n\"+\n",
"\" pd_controls.include_keys || []\\n\"+\n",
"\" addOptions(curCell._metadata.pixiedust.displayParams || {}, pd_controls.useCellMetadata, ignoreKeys);\\n\"+\n",
"\" }else{\\n\"+\n",
"\" \\n\"+\n",
"\" var includeKeys = pd_controls.include_keys || [];\\n\"+\n",
"\" var includeOptions = {};\\n\"+\n",
"\" for (var key in (curCell._metadata.pixiedust.displayParams||{})){\\n\"+\n",
"\" if (includeKeys.indexOf(key) > -1 || !(key in pd_controls.options)){\\n\"+\n",
"\" includeOptions[key] = curCell._metadata.pixiedust.displayParams[key];\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" addOptions(includeOptions);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" addOptions(user_controls.options||{});\\n\"+\n",
"\" var pattern = \\\"\\\\\\\\w*\\\\\\\\s*=\\\\\\\\s*'(\\\\\\\\\\\\\\\\'|[^'])*'\\\";\\n\"+\n",
"\" var rpattern=new RegExp(pattern,\\\"g\\\");\\n\"+\n",
"\" var n = command.match(rpattern);\\n\"+\n",
"\" \\n\"+\n",
"\" var org_params = {}\\n\"+\n",
"\" for (var i=0; i<n.length;i++){\\n\"+\n",
"\" var parts = n[i].split(\\\"=\\\")\\n\"+\n",
"\" if (parts[0].trim() == \\\"org_params\\\"){\\n\"+\n",
"\" var value = parts[1].trim()\\n\"+\n",
"\" var values = value.substring(1,value.length-1).split(\\\",\\\");\\n\"+\n",
"\" for (var p in values){\\n\"+\n",
"\" org_params[values[p].trim()] = true;\\n\"+\n",
"\" }\\n\"+\n",
"\" break;\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" var displayParams={}\\n\"+\n",
"\" for (var i = 0; i < n.length; i++){\\n\"+\n",
"\" var parts=n[i].split(\\\"=\\\");\\n\"+\n",
"\" var key = parts[0].trim();\\n\"+\n",
"\" var value = parts[1].trim()\\n\"+\n",
"\" if (!key.startsWith(\\\"nostore_\\\") && key != \\\"showchrome\\\" && key != \\\"prefix\\\" && key != \\\"cell_id\\\" && key != \\\"org_params\\\" && !!!org_params[key]){\\n\"+\n",
"\" displayParams[key] = value.substring(1,value.length-1);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" \\n\"+\n",
"\"\\n\"+\n",
"\" \\n\"+\n",
"\" var rpattern=/,(.*?)='(.*?)'/g;\\n\"+\n",
"\" var newOptions = {};\\n\"+\n",
"\" for (var match = rpattern.exec(command); match != null; match = rpattern.exec(command)){\\n\"+\n",
"\" newOptions[match[1]] = match[2];\\n\"+\n",
"\" }\\n\"+\n",
"\" pd_controls.options = newOptions;\\n\"+\n",
"\" pd_controls.command = command;\\n\"+\n",
"\" }\\n\"+\n",
"\" if(curCell&&curCell.output_area){ \\n\"+\n",
"\" if ( !user_controls.nostoreMedatadata ){\\n\"+\n",
"\" curCell._metadata.pixiedust = curCell._metadata.pixiedust || {}\\n\"+\n",
"\" curCell._metadata.pixiedust.displayParams=displayParams\\n\"+\n",
"\" curCell.output_area.outputs=[];\\n\"+\n",
"\" var old_msg_id = curCell.last_msg_id;\\n\"+\n",
"\" if (old_msg_id) {\\n\"+\n",
"\" curCell.kernel.clear_callbacks_for_msg(old_msg_id);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" }else{\\n\"+\n",
"\" console.log(\\\"couldn't find the cell\\\");\\n\"+\n",
"\" }\\n\"+\n",
"\" $('#wrapperJS' + pd_prefix).html(\\\"\\\")\\n\"+\n",
"\" if (!getTargetNode().hasClass( \\\"no_loading_msg\\\" )){\\n\"+\n",
"\" setHTML(getTargetNode(), \\n\"+\n",
"\" '<div style=\\\"width:100px;height:60px;left:47%;position:relative\\\">'+\\n\"+\n",
"\" '<i class=\\\"fa fa-circle-o-notch fa-spin\\\" style=\\\"font-size:48px\\\"></i>'+\\n\"+\n",
"\" '</div>'+\\n\"+\n",
"\" '<div style=\\\"text-align:center\\\">' +\\n\"+\n",
"\" (getTargetNode().attr(\\\"pd_loading_msg\\\") || \\\"Loading your data. Please wait...\\\") +\\n\"+\n",
"\" '</div>',\\n\"+\n",
"\" pd_controls, user_controls\\n\"+\n",
"\" );\\n\"+\n",
"\" }\\n\"+\n",
"\" \\n\"+\n",
"\" if (curCell && checkRootInit() && curCell._metadata.pixiedust && curCell._metadata.pixiedust.pixieapp){\\n\"+\n",
"\" pd_controls.entity = pd_controls.entity || []\\n\"+\n",
"\" if (pd_controls.entity.length == 1 && (pd_controls.options.nostore_pixieapp == pd_controls.entity[0])){\\n\"+\n",
"\" console.log(\\\"Initializing pixieapp metadata\\\");\\n\"+\n",
"\" command = pd_controls.options.nostore_pixieapp + \\\".append_metadata(\\\" + \\n\"+\n",
"\" JSON.stringify(curCell._metadata.pixiedust.pixieapp) + \\\")\\\\n\\\" + command\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" if (user_controls.send_input_reply){\\n\"+\n",
"\" command = user_controls.send_input_reply;\\n\"+\n",
"\" callbacks.answer_input_reply = user_controls.answer_input_reply;\\n\"+\n",
"\" \\n\"+\n",
"\" pixiedust.input_reply_queue.queue = pixiedust.input_reply_queue.queue.filter(\\n\"+\n",
"\" function(item){\\n\"+\n",
"\" return item.command!='no_op';\\n\"+\n",
"\" }\\n\"+\n",
"\" );\\n\"+\n",
"\" if (pixiedust.input_reply_queue.inflight || pixiedust.input_reply_queue.queue.length > 0 || command == \\\"no_op_delay\\\"){\\n\"+\n",
"\" pixiedust.input_reply_queue.queue.push({\\\"command\\\":command, \\\"callbacks\\\":callbacks});\\n\"+\n",
"\" }else{\\n\"+\n",
"\" send_input_reply(callbacks, command, pd_controls);\\n\"+\n",
"\" }\\n\"+\n",
"\" }else{\\n\"+\n",
"\" if (pixiedust.input_reply_queue.inflight){\\n\"+\n",
"\" console.log(\\\"Warning: A kernel request is triggered but not all the reply callback where consummed\\\", command);\\n\"+\n",
"\" }\\n\"+\n",
"\" command = command.trim();\\n\"+\n",
"\" IPython.notebook.session.kernel.execute(command, callbacks, {\\n\"+\n",
"\" silent:true,store_history:false,stop_on_error:true,allow_stdin : true\\n\"+\n",
"\" });\\n\"+\n",
"\" }\\n\"+\n",
"\" \\n\"+\n",
"\"\\n\"+\n",
"\" console.log(\\\"Running command2:\\\\n\\\",command);\\n\"+\n",
"\" }\\n\"+\n",
"\"}()\\n\"+\n",
"\" },\\n\"+\n",
"\" executeInDialog:function(pd_controls, user_controls){\\n\"+\n",
"\" pd_controls = pd_controls || {};\\n\"+\n",
"\" user_controls = user_controls || {\\\"options\\\":{}};\\n\"+\n",
"\" var displayOptions = $.extend({}, pd_controls.options || {}, user_controls.options || {} );\\n\"+\n",
"\" var global={};\\n\"+\n",
"\" var sourceDivId = displayOptions.targetDivId;\\n\"+\n",
"\" require(['base/js/dialog'],function(dialog){\\n\"+\n",
"\" var modal = dialog.modal;\\n\"+\n",
"\" var attr_pd_ctrl = JSON.stringify(pd_controls).trim()\\n\"+\n",
"\" .replace(/&/g, '&amp;')\\n\"+\n",
"\" .replace(/'/g, '&apos;')\\n\"+\n",
"\" .replace(/\\\"/g, '&quot;')\\n\"+\n",
"\" .replace(/</g, '&lt;')\\n\"+\n",
"\" .replace(/>/g, '&gt;');\\n\"+\n",
"\" var dialogRoot = \\\"dialog\\\" + pd_controls.prefix + \\\"root\\\";\\n\"+\n",
"\" var options = {\\n\"+\n",
"\" title: \\\"PixieDust: \\\" + (displayOptions.title || \\\"Dialog\\\"),\\n\"+\n",
"\" body: '<div id=\\\"' + dialogRoot + '\\\" pixiedust=\\\"' + attr_pd_ctrl + '\\\" class=\\\"pixiedust\\\"></div>',\\n\"+\n",
"\" sanitize:false,\\n\"+\n",
"\" notebook: IPython.notebook,\\n\"+\n",
"\" keyboard_manager: IPython.notebook.keyboard_manager,\\n\"+\n",
"\" maximize_modal: (displayOptions.maximize === \\\"true\\\"),\\n\"+\n",
"\" custom_class: (displayOptions.customClass || ''),\\n\"+\n",
"\" hide_header: (displayOptions.hideHeader === 'true'),\\n\"+\n",
"\" hide_footer: (displayOptions.showFooter === undefined || displayOptions.showFooter !== 'true'),\\n\"+\n",
"\" buttons: {\\n\"+\n",
"\" OK: {\\n\"+\n",
"\" class : \\\"btn-primary btn-ok\\\",\\n\"+\n",
"\" click: function() {\\n\"+\n",
"\" var dlg = $(\\\"#\\\" + dialogRoot + \\\" > pd_dialog\\\");\\n\"+\n",
"\" try{\\n\"+\n",
"\" pixiedust.dialogRoot = null;\\n\"+\n",
"\" $(document).trigger('pd_event', {targetDivId: sourceDivId || dialogRoot, entity: pd_controls.options.nostore_pixieapp});\\n\"+\n",
"\" return new Function('global', 'modal_obj', dlg.find(\\\"> pd_ok\\\").text().trim())(global, modal_obj);\\n\"+\n",
"\" }catch(e){\\n\"+\n",
"\" console.error(e);\\n\"+\n",
"\" return false;\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" },\\n\"+\n",
"\" Cancel: {\\n\"+\n",
"\" class : \\\"btn-cancel\\\",\\n\"+\n",
"\" click: function(){\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" };\\n\"+\n",
"\"\\n\"+\n",
"\" function resizeDialog() {\\n\"+\n",
"\" global.modalBodyStyle = $('.pixiedust .modal-body').attr('style');\\n\"+\n",
"\" global.modalFooterStyle = $('.pixiedust .modal-footer').attr('style');\\n\"+\n",
"\" $('.pixiedust .modal-body').attr('style', global.modalBodyStyle ? global.modalBodyStyle + ';padding:5px 20px !important;' : 'padding:5px 20px !important;');\\n\"+\n",
"\" if (options.hide_footer){\\n\"+\n",
"\" $('.pixiedust .modal-footer').attr('style', 'display:none !important;');\\n\"+\n",
"\" }\\n\"+\n",
"\" $(\\\".pixiedust .modal-footer\\\").find(\\\"> button:contains('OK')\\\").attr(\\\"pd_options\\\", \\\"toto=true\\\");\\n\"+\n",
"\" if (options.hide_header) {\\n\"+\n",
"\" global.modalHeaderStyle = $('.pixiedust .modal-header').attr('style');\\n\"+\n",
"\" $('.pixiedust .modal-header').attr('style', 'display:none !important;');\\n\"+\n",
"\" }\\n\"+\n",
"\" };\\n\"+\n",
"\"\\n\"+\n",
"\" function resetDialog() {\\n\"+\n",
"\" if (global.modalBodyStyle) {\\n\"+\n",
"\" $('.pixiedust .modal-body').attr('style', global.modalBodyStyle);\\n\"+\n",
"\" } else {\\n\"+\n",
"\" $('.pixiedust .modal-body').removeAttr('style');\\n\"+\n",
"\" }\\n\"+\n",
"\" if (global.modalFooterStyle) {\\n\"+\n",
"\" $('.pixiedust .modal-footer').attr('style', global.modalFooterStyle);\\n\"+\n",
"\" } else {\\n\"+\n",
"\" $('.pixiedust .modal-footer').removeAttr('style');\\n\"+\n",
"\" }\\n\"+\n",
"\" if (global.modalHeaderStyle) {\\n\"+\n",
"\" $('.pixiedust .modal-header').attr('style', global.modalHeaderStyle);\\n\"+\n",
"\" } else {\\n\"+\n",
"\" $('.pixiedust .modal-header').removeAttr('style');\\n\"+\n",
"\" }\\n\"+\n",
"\" };\\n\"+\n",
"\"\\n\"+\n",
"\" var modal_obj = modal(options);\\n\"+\n",
"\" modal_obj.addClass('pixiedust pixiedust-app ' + options.custom_class);\\n\"+\n",
"\" if (options.maximize_modal) {\\n\"+\n",
"\" modal_obj.addClass('pixiedust pixiedust-app pixiedust-maximize ' + options.custom_class);\\n\"+\n",
"\" }\\n\"+\n",
"\" modal_obj.on('shown.bs.modal', function(){\\n\"+\n",
"\" resizeDialog();\\n\"+\n",
"\" var isFF = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;\\n\"+\n",
"\" if( isFF && options.keyboard_manager){\\n\"+\n",
"\" \\n\"+\n",
"\" var KeyboardManager = require('notebook/js/keyboardmanager').KeyboardManager;\\n\"+\n",
"\" global.KMEnableProto = KeyboardManager.prototype.enable;\\n\"+\n",
"\" KeyboardManager.prototype.enable = function () {\\n\"+\n",
"\" this.enabled = false;\\n\"+\n",
"\" };\\n\"+\n",
"\" }\\n\"+\n",
"\" IPython.keyboard_manager.register_events(modal_obj);\\n\"+\n",
"\" user_controls.options.targetDivId = user_controls.targetDivId = dialogRoot;\\n\"+\n",
"\" if ( user_controls.options.dialog == 'true'){\\n\"+\n",
"\" user_controls.onDisplayDone = function(){\\n\"+\n",
"\" var dlg = $(\\\"#\\\" + dialogRoot + \\\" > pd_dialog\\\")\\n\"+\n",
"\" try{\\n\"+\n",
"\" new Function('global', 'modal_obj', dlg.find(\\\"> pd_onload\\\").text().trim())(global, modal_obj);\\n\"+\n",
"\" }catch(e){\\n\"+\n",
"\" console.error(e);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" pixiedust.dialogRoot = dialogRoot;\\n\"+\n",
"\" pixiedust.executeDisplay(pd_controls, user_controls);\\n\"+\n",
"\" });\\n\"+\n",
"\" modal_obj.on(\\\"hidden.bs.modal\\\", function () {\\n\"+\n",
"\" resetDialog();\\n\"+\n",
"\" if ( global.KMEnableProto ){\\n\"+\n",
"\" var KeyboardManager = require('notebook/js/keyboardmanager').KeyboardManager;\\n\"+\n",
"\" KeyboardManager.prototype.enable = global.KMEnableProto;\\n\"+\n",
"\" delete global.KMEnableProto;\\n\"+\n",
"\" }\\n\"+\n",
"\" pixiedust.dialogRoot = null;\\n\"+\n",
"\" });\\n\"+\n",
"\" })\\n\"+\n",
"\" },\\n\"+\n",
"\" sendEvent: function(payload, divId){\\n\"+\n",
"\" payload = payload || {};\\n\"+\n",
"\" var targetElement = event.target || event.srcElement;\\n\"+\n",
"\" divId = divId || $(targetElement).uniqueId().attr('id');\\n\"+\n",
"\" payload.targetDivId = divId;\\n\"+\n",
"\" $(document).trigger('pd_event', payload);\\n\"+\n",
"\" },\\n\"+\n",
"\" saveOutputInCell: function(curCell, content, html, msg_type){\\n\"+\n",
"\" if(curCell && curCell.output_area && curCell.output_area.outputs){\\n\"+\n",
"\" var data = JSON.parse(JSON.stringify(content.data));\\n\"+\n",
"\" if(!!data[\\\"text/html\\\"])data[\\\"text/html\\\"]=html;\\n\"+\n",
"\" function savedData(data){\\n\"+\n",
"\" \\n\"+\n",
"\" var markup='<style type=\\\"text/css\\\">.pd_warning{display:none;}</style>';\\n\"+\n",
"\" markup+='<div class=\\\"pd_warning\\\"><em>Hey, there\\\\'s something awesome here! To see it, open this notebook outside GitHub, in a viewer like Jupyter</em></div>';\\n\"+\n",
"\" nodes = $.parseHTML(data[\\\"text/html\\\"], null, true);\\n\"+\n",
"\" var s = $(nodes).wrap(\\\"<div>\\\").parent().find(\\\".pd_save\\\").not(\\\".pd_save .pd_save\\\");\\n\"+\n",
"\" s.each(function(){\\n\"+\n",
"\" var found = false;\\n\"+\n",
"\" if ( $(this).attr(\\\"id\\\") ){\\n\"+\n",
"\" var n = $(\\\"#\\\" + $(this).attr(\\\"id\\\"));\\n\"+\n",
"\" if (n.length>0){\\n\"+\n",
"\" found=true;\\n\"+\n",
"\" n.each(function(){\\n\"+\n",
"\" $(this).addClass(\\\"is-viewer-good\\\");\\n\"+\n",
"\" });\\n\"+\n",
"\" markup+=n.wrap(\\\"<div>\\\").parent().html();\\n\"+\n",
"\" }\\n\"+\n",
"\" }else{\\n\"+\n",
"\" $(this).addClass(\\\"is-viewer-good\\\");\\n\"+\n",
"\" }\\n\"+\n",
"\" if (!found){\\n\"+\n",
"\" markup+=$(this).parent().html();\\n\"+\n",
"\" }\\n\"+\n",
"\" });\\n\"+\n",
"\" data[\\\"text/html\\\"] = markup;\\n\"+\n",
"\" return data;\\n\"+\n",
"\" }\\n\"+\n",
"\" curCell.output_area.outputs = [{\\n\"+\n",
"\" \\\"data\\\": savedData(data),\\\"metadata\\\":content.metadata,\\\"output_type\\\":msg_type\\n\"+\n",
"\" }];\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\"})();\\n\"+\n",
"\"\\n\"+\n",
"\"function resolveScriptMacros(script){\\n\"+\n",
"\" script = script && script.replace(/\\\\$val\\\\(\\\\\\\"?(\\\\w*)\\\\\\\"?\\\\)/g, function(a,b){\\n\"+\n",
"\" var n = $(\\\"#\\\" + b );\\n\"+\n",
"\" var v = null;\\n\"+\n",
"\" if (n.length > 0){\\n\"+\n",
"\" if (n.is(':checkbox')){\\n\"+\n",
"\" v = n.is(':checked').toString();\\n\"+\n",
"\" }else{\\n\"+\n",
"\" v = $(\\\"#\\\" + b ).val() || $(\\\"#\\\" + b ).text();\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" if (!v && v!==\\\"\\\" && window[b] && typeof window[b] === \\\"function\\\"){\\n\"+\n",
"\" v = window[b]();\\n\"+\n",
"\" }\\n\"+\n",
"\" if (!v && v!==\\\"\\\" && pixiedust[b] && typeof pixiedust[b] === \\\"function\\\"){\\n\"+\n",
"\" v = pixiedust[b]();\\n\"+\n",
"\" }\\n\"+\n",
"\" if (!v && v!==\\\"\\\"){\\n\"+\n",
"\" console.log(\\\"Warning: Unable to resolve value for element \\\", b);\\n\"+\n",
"\" return a;\\n\"+\n",
"\" }\\n\"+\n",
"\" if (typeof v === \\\"object\\\"){\\n\"+\n",
"\" return JSON.stringify(v)\\n\"+\n",
"\" .split('\\\\\\\\').join('\\\\\\\\\\\\\\\\')\\n\"+\n",
"\" .split(\\\"'''\\\").join(\\\"\\\\\\\\'\\\\\\\\'\\\\\\\\'\\\")\\n\"+\n",
"\" .split('\\\"\\\"\\\"').join('\\\\\\\\\\\"\\\\\\\\\\\"\\\\\\\\\\\"')\\n\"+\n",
"\" }\\n\"+\n",
"\" return v.split('\\\"').join('&quot;').split('\\\\n').join('\\\\\\\\n');\\n\"+\n",
"\" });\\n\"+\n",
"\" return script;\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\"function getParentScript(element){\\n\"+\n",
"\" var scripts = [];\\n\"+\n",
"\" \\n\"+\n",
"\" $(element).parents(\\\"[pd_script]\\\").each(function(){\\n\"+\n",
"\" scripts.unshift(this.getAttribute(\\\"pd_script\\\"));\\n\"+\n",
"\" });\\n\"+\n",
"\"\\n\"+\n",
"\" \\n\"+\n",
"\" var script = \\\"\\\";\\n\"+\n",
"\" $.each( scripts, function(index, value){\\n\"+\n",
"\" if (value){\\n\"+\n",
"\" script += \\\"\\\\n\\\" + value;\\n\"+\n",
"\" }\\n\"+\n",
"\" });\\n\"+\n",
"\" return script;\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\"function preRun(element){\\n\"+\n",
"\" var preRunCode = getScriptOfType(element, \\\"preRun\\\");\\n\"+\n",
"\" if (!preRunCode ){\\n\"+\n",
"\" return true;\\n\"+\n",
"\" }\\n\"+\n",
"\" return new Function(preRunCode.trim())();\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\"function getScriptOfType(element, scriptType){\\n\"+\n",
"\" if (!element.jquery){\\n\"+\n",
"\" element = $(element);\\n\"+\n",
"\" }\\n\"+\n",
"\" var code = null;\\n\"+\n",
"\" element.find(\\\"> pd_script\\\").each(function(){\\n\"+\n",
"\" var type = this.getAttribute(\\\"type\\\");\\n\"+\n",
"\" if (type == scriptType){\\n\"+\n",
"\" code = $(this).text();\\n\"+\n",
"\" }\\n\"+\n",
"\" });\\n\"+\n",
"\" if (code){\\n\"+\n",
"\" return code.trim();\\n\"+\n",
"\" }\\n\"+\n",
"\" return code;\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\"function addOptions(command, options, override=true){\\n\"+\n",
"\" function getStringRep(v) {\\n\"+\n",
"\" if (typeof v === 'string' || v instanceof String){\\n\"+\n",
"\" v = v.replace(/'/g,\\\"\\\\\\\\\\\\'\\\");\\n\"+\n",
"\" }\\n\"+\n",
"\" return \\\"'\\\" + v + \\\"'\\\";\\n\"+\n",
"\" }\\n\"+\n",
"\" for (var key in (options||{})){\\n\"+\n",
"\" var value = options[key];\\n\"+\n",
"\" var hasValue = value != null && typeof value !== 'undefined' && value !== '';\\n\"+\n",
"\" var replaceValue = hasValue ? (key+\\\"=\\\" + getStringRep(value) ) : \\\"\\\";\\n\"+\n",
"\" var pattern = (hasValue?\\\"\\\":\\\",\\\")+\\\"\\\\\\\\s*\\\" + key + \\\"\\\\\\\\s*=\\\\\\\\s*'(\\\\\\\\\\\\\\\\'|[^'])*'\\\";\\n\"+\n",
"\" var rpattern=new RegExp(pattern);\\n\"+\n",
"\" var n = command.search(rpattern);\\n\"+\n",
"\" if ( n >= 0 ){\\n\"+\n",
"\" if (override){\\n\"+\n",
"\" command = command.replace(rpattern, replaceValue);\\n\"+\n",
"\" }\\n\"+\n",
"\" }else if (hasValue && command.search(/display\\\\s*\\\\(/) >= 0 ){\\n\"+\n",
"\" var n = command.lastIndexOf(\\\")\\\");\\n\"+\n",
"\" command = [command.slice(0, n), (command[n-1]==\\\"(\\\"? \\\"\\\":\\\",\\\") + replaceValue, command.slice(n)].join('')\\n\"+\n",
"\" } \\n\"+\n",
"\" }\\n\"+\n",
"\" return command;\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\"function computeGeometry(element, execInfo){\\n\"+\n",
"\" var parentStyles = [];\\n\"+\n",
"\" var hiddenBlockStyle = 'visibility: hidden !important; display: block !important;';\\n\"+\n",
"\" var tDiv = $(\\\"#\\\" + execInfo.targetDivId);\\n\"+\n",
"\" var tDivParents = tDiv.parents().addBack().filter(':hidden');\\n\"+\n",
"\" tDivParents.each(function() {\\n\"+\n",
"\" var currentStyle = $(this).attr('style');\\n\"+\n",
"\" parentStyles.push(currentStyle);\\n\"+\n",
"\" $(this).attr('style', currentStyle ? currentStyle + ';' + hiddenBlockStyle : hiddenBlockStyle);\\n\"+\n",
"\" });\\n\"+\n",
"\"\\n\"+\n",
"\" w = tDiv.width()\\n\"+\n",
"\" if (w) {\\n\"+\n",
"\" execInfo.options.nostore_cw= w;\\n\"+\n",
"\" }\\n\"+\n",
"\" if ($(element).parents(\\\".modal-dialog\\\").length > 0 ) {\\n\"+\n",
"\" h = tDiv.height()\\n\"+\n",
"\" if (h) {\\n\"+\n",
"\" execInfo.options.nostore_ch = h-10;\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" tDivParents.each(function(i) {\\n\"+\n",
"\" if (parentStyles[i] === undefined) {\\n\"+\n",
"\" $(this).removeAttr('style');\\n\"+\n",
"\" } else {\\n\"+\n",
"\" $(this).attr('style', parentStyles[i]);\\n\"+\n",
"\" }\\n\"+\n",
"\" });\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\"function readScriptAttribute(element){\\n\"+\n",
"\" var retValue = element.getAttribute(\\\"pd_script\\\");\\n\"+\n",
"\" var run_raw = false;\\n\"+\n",
"\" if (!retValue){\\n\"+\n",
"\" $(element).find(\\\"> pd_script\\\").each(function(){\\n\"+\n",
"\" var type = this.getAttribute(\\\"type\\\");\\n\"+\n",
"\" if (!type || type==\\\"python\\\"){\\n\"+\n",
"\" retValue = $(this).text();\\n\"+\n",
"\" run_raw = this.hasAttribute(\\\"run_raw\\\");\\n\"+\n",
"\" }\\n\"+\n",
"\" })\\n\"+\n",
"\" }\\n\"+\n",
"\" return retValue?{\\\"script\\\":retValue, \\\"run_raw\\\":run_raw}:null;\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\"function getAttribute(element, name, defValue, defValueIfKeyAlone){\\n\"+\n",
"\" if (!element.hasAttribute(name)){\\n\"+\n",
"\" return defValue;\\n\"+\n",
"\" }\\n\"+\n",
"\" retValue = element.getAttribute(name);\\n\"+\n",
"\" return retValue || defValueIfKeyAlone;\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\"function convertToBoolean(value, def){\\n\"+\n",
"\" if (value === undefined){\\n\"+\n",
"\" return def;\\n\"+\n",
"\" }\\n\"+\n",
"\" if (typeof(value) == \\\"string\\\"){\\n\"+\n",
"\" return value.toLowerCase() == \\\"true\\\";\\n\"+\n",
"\" }\\n\"+\n",
"\" return value;\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\"function readExecInfo(pd_controls, element, searchParents, fromExecInfo){\\n\"+\n",
"\" if (searchParents === null || searchParents === undefined ){\\n\"+\n",
"\" searchParents = !element.hasAttribute(\\\"pd_stop_propagation\\\");\\n\"+\n",
"\" }\\n\"+\n",
"\" var execInfo = {\\\"options\\\":{}};\\n\"+\n",
"\" $.extend(execInfo, fromExecInfo || {});\\n\"+\n",
"\" var hasOptions = false;\\n\"+\n",
"\" $.each( element.attributes, function(){\\n\"+\n",
"\" if (this.name.startsWith(\\\"option_\\\")){\\n\"+\n",
"\" hasOptions = true;\\n\"+\n",
"\" execInfo.options[this.name.replace(\\\"option_\\\", \\\"\\\")] = this.value || null;\\n\"+\n",
"\" }\\n\"+\n",
"\" });\\n\"+\n",
"\" var pd_options = resolveScriptMacros(element.getAttribute(\\\"pd_options\\\"));\\n\"+\n",
"\" if (pd_options){\\n\"+\n",
"\" var parts = pd_options.split(\\\";\\\");\\n\"+\n",
"\" $.each( parts, function(){\\n\"+\n",
"\" var index = this.indexOf(\\\"=\\\");\\n\"+\n",
"\" if ( index > 0){\\n\"+\n",
"\" hasOptions = true;\\n\"+\n",
"\" execInfo.options[this.substring(0, index)] = this.substring(index+1);\\n\"+\n",
"\" }\\n\"+\n",
"\" });\\n\"+\n",
"\" }\\n\"+\n",
"\" \\n\"+\n",
"\" $(element).find(\\\"> pd_options\\\").each(function(){\\n\"+\n",
"\" try{\\n\"+\n",
"\" var options = JSON.parse($(this).text());\\n\"+\n",
"\" hasOptions = true;\\n\"+\n",
"\" for (var key in options) { \\n\"+\n",
"\" execInfo.options[key] = resolveScriptMacros(options[key]); \\n\"+\n",
"\" }\\n\"+\n",
"\" }catch(e){\\n\"+\n",
"\" console.log(\\\"Error parsing pd_options, invalid json\\\", e);\\n\"+\n",
"\" }\\n\"+\n",
"\" })\\n\"+\n",
"\" if (convertToBoolean(execInfo.options.nostore_figureOnly, true)){\\n\"+\n",
"\" execInfo.options.nostore_figureOnly = true;\\n\"+\n",
"\" }else{\\n\"+\n",
"\" delete execInfo.options.nostore_figureOnly;\\n\"+\n",
"\" }\\n\"+\n",
"\" execInfo.options.targetDivId = execInfo.targetDivId = pd_controls.refreshTarget || element.getAttribute(\\\"pd_target\\\");\\n\"+\n",
"\" if (execInfo.options.targetDivId){\\n\"+\n",
"\" execInfo.options.no_margin=true;\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" execInfo.options.widget = element.getAttribute(\\\"pd_widget\\\");\\n\"+\n",
"\" execInfo.pixieapp = element.getAttribute(\\\"pd_app\\\");\\n\"+\n",
"\" if (execInfo.pixieapp && !execInfo.targetDivId){\\n\"+\n",
"\" execInfo.options.targetDivId = execInfo.targetDivId = $(element).uniqueId().attr('id');\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" computeGeometry(element, execInfo);\\n\"+\n",
"\"\\n\"+\n",
"\" scriptAttr = readScriptAttribute(element);\\n\"+\n",
"\" if (scriptAttr){\\n\"+\n",
"\" execInfo.script = (execInfo.script || \\\"\\\") + \\\"\\\\n\\\" + scriptAttr.script;\\n\"+\n",
"\" execInfo.script_run_raw = scriptAttr.run_raw;\\n\"+\n",
"\" }\\n\"+\n",
"\" execInfo.refresh = execInfo.refresh || (getAttribute(element, \\\"pd_refresh\\\", \\\"false\\\", \\\"true\\\") == 'true');\\n\"+\n",
"\" execInfo.norefresh = element.hasAttribute(\\\"pd_norefresh\\\");\\n\"+\n",
"\" execInfo.entity = element.hasAttribute(\\\"pd_entity\\\") ? resolveScriptMacros(element.getAttribute(\\\"pd_entity\\\")) || \\\"pixieapp_entity\\\" : null;\\n\"+\n",
"\" function applyEntity(c, e, doptions){\\n\"+\n",
"\" \\n\"+\n",
"\" doptions.prefix = pd_controls.prefix;\\n\"+\n",
"\"\\n\"+\n",
"\" pd_controls.sniffers = pd_controls.sniffers || [];\\n\"+\n",
"\" pd_controls.sniffers.forEach(function(sniffer){\\n\"+\n",
"\" c = addOptions(c, eval('(' + sniffer + ')')) \\n\"+\n",
"\" });\\n\"+\n",
"\" if (!e){\\n\"+\n",
"\" return addOptions(c, doptions);\\n\"+\n",
"\" }\\n\"+\n",
"\" if (pd_controls.entity){\\n\"+\n",
"\" c = c.replace(pd_controls.entity, pd_controls.entity+ \\\".\\\" + e );\\n\"+\n",
"\" }else{\\n\"+\n",
"\" c = c.replace(/\\\\((\\\\w*),/, \\\"($1.\\\" + e + \\\",\\\");\\n\"+\n",
"\" } \\n\"+\n",
"\" return addOptions(c, doptions);\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" var hasRefreshTarget = element.hasAttribute(\\\"pd_refresh\\\") && \\n\"+\n",
"\" element.getAttribute(\\\"pd_refresh\\\") != \\\"true\\\" &&\\n\"+\n",
"\" element.getAttribute(\\\"pd_refresh\\\") != \\\"false\\\";\\n\"+\n",
"\" if ( (!hasOptions && (execInfo.refresh || hasRefreshTarget || execInfo.options.widget) && !execInfo.script) \\n\"+\n",
"\" || (!execInfo.script && execInfo.pixieapp)){\\n\"+\n",
"\" execInfo.script = \\\"#refresh\\\";\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" var dialog = (execInfo.options.dialog == \\\"true\\\");\\n\"+\n",
"\" if ( dialog ){\\n\"+\n",
"\" execInfo.script = execInfo.script || \\\"#refresh\\\";\\n\"+\n",
"\" execInfo.refresh = true;\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" if (execInfo.script){\\n\"+\n",
"\" execInfo.script = execInfo.script.trim()\\n\"+\n",
"\" \\n\"+\n",
"\" var entity = pd_controls.entity;\\n\"+\n",
"\" if (!entity){\\n\"+\n",
"\" var match = pd_controls.command.match(/display\\\\((\\\\w*),/);\\n\"+\n",
"\" if (match){\\n\"+\n",
"\" entity = match[1];\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" if (entity){\\n\"+\n",
"\" var prolog = \\\"\\\";\\n\"+\n",
"\" if (!execInfo.script_run_raw){\\n\"+\n",
"\" console.log(\\\"Inject self with entity\\\", entity);\\n\"+\n",
"\" prolog = \\\"from pixiedust.utils.shellAccess import ShellAccess\\\\n\\\"+\\n\"+\n",
"\" \\\"self=ShellAccess['\\\" + entity + \\\"']\\\\n\\\";\\n\"+\n",
"\" }\\n\"+\n",
"\" execInfo.script = prolog +\\n\"+\n",
"\" resolveScriptMacros( getParentScript(element) ) + '\\\\n' +\\n\"+\n",
"\" resolveScriptMacros(execInfo.script);\\n\"+\n",
"\" if ( execInfo.pixieapp){\\n\"+\n",
"\" var locOptions = execInfo.options;\\n\"+\n",
"\" locOptions.cell_id = pd_controls.options.cell_id;\\n\"+\n",
"\" locOptions.prefix = pd_controls.prefix;\\n\"+\n",
"\" if (pd_controls.options.nostore_cw){\\n\"+\n",
"\" locOptions.nostore_cw = pd_controls.options.nostore_cw\\n\"+\n",
"\" }\\n\"+\n",
"\" function makePythonStringOrNone(s){\\n\"+\n",
"\" return !s?\\\"None\\\":('\\\"\\\"\\\"' + s + '\\\"\\\"\\\"')\\n\"+\n",
"\" }\\n\"+\n",
"\" function getCellMetadata(){\\n\"+\n",
"\" var cell = pixiedust.getCell(execInfo.options.cell_id);\\n\"+\n",
"\" var retValue = cell?cell._metadata:{};\\n\"+\n",
"\" return JSON.stringify(retValue || {});\\n\"+\n",
"\" }\\n\"+\n",
"\" execInfo.script += \\\"\\\\nfrom pixiedust.display.app.pixieapp import runPixieApp\\\" + \\n\"+\n",
"\" \\\"\\\\ntrue=True\\\\nfalse=False\\\\nnull=None\\\" +\\n\"+\n",
"\" \\\"\\\\nrunPixieApp('\\\" + \\n\"+\n",
"\" execInfo.pixieapp + \\\"', options=\\\" + JSON.stringify(locOptions) \\n\"+\n",
"\" + \\\",parent_command=\\\" + makePythonStringOrNone(applyEntity(pd_controls.command, execInfo.entity, execInfo.options))\\n\"+\n",
"\" + \\\",parent_pixieapp=\\\" + makePythonStringOrNone(pd_controls.options.nostore_pixieapp)\\n\"+\n",
"\" + \\\",cell_metadata=\\\" + getCellMetadata()\\n\"+\n",
"\" + \\\")\\\";\\n\"+\n",
"\" }else if ( ( hasOptions || execInfo.refresh || execInfo.entity || execInfo.options.widget) && \\n\"+\n",
"\" !execInfo.norefresh && $(element).children(\\\"target[pd_target]\\\").length == 0){\\n\"+\n",
"\" \\n\"+\n",
"\" execInfo.script += \\\"\\\\n\\\" + applyEntity(pd_controls.command, execInfo.entity, execInfo.options)\\n\"+\n",
"\" }else{\\n\"+\n",
"\" \\n\"+\n",
"\" execInfo.targetDivId=execInfo.targetDivId || \\\"pixiedust_dummy\\\";\\n\"+\n",
"\" }\\n\"+\n",
"\" }else{\\n\"+\n",
"\" console.log(\\\"Unable to extract entity variable from command\\\", pd_controls.command);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" if (!hasOptions && !execInfo.targetDivId && !execInfo.script){\\n\"+\n",
"\" if (!searchParents){\\n\"+\n",
"\" return null;\\n\"+\n",
"\" }\\n\"+\n",
"\" return element.hasAttribute(\\\"pixiedust\\\")?null:readExecInfo(pd_controls, element.parentElement);\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" if (!execInfo.script){\\n\"+\n",
"\" execInfo.script = applyEntity(pd_controls.command, execInfo.entity, execInfo.options);\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" \\n\"+\n",
"\" execInfo.nostoreMedatadata = true;\\n\"+\n",
"\"\\n\"+\n",
"\" \\n\"+\n",
"\" if ( pixiedust.dialogRoot ){\\n\"+\n",
"\" execInfo.targetDivId = execInfo.targetDivId || pixiedust.dialogRoot;\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" if (\\\"send_input_reply\\\" in execInfo.options){\\n\"+\n",
"\" execInfo.send_input_reply = execInfo.options[\\\"send_input_reply\\\"];\\n\"+\n",
"\" delete execInfo.options[\\\"send_input_reply\\\"];\\n\"+\n",
"\" }\\n\"+\n",
"\" if (\\\"answer_input_reply\\\" in execInfo.options){\\n\"+\n",
"\" execInfo.answer_input_reply = execInfo.options[\\\"answer_input_reply\\\"];\\n\"+\n",
"\" delete execInfo.options[\\\"answer_input_reply\\\"];\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" execInfo.execute = function(){\\n\"+\n",
"\" \\n\"+\n",
"\" if (!preRun(element)){\\n\"+\n",
"\" return;\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" pd_controls.sniffers = pd_controls.sniffers || [];\\n\"+\n",
"\" pd_controls.sniffers.forEach(function(sniffer){\\n\"+\n",
"\" if (this.script){\\n\"+\n",
"\" this.script = addOptions(this.script, eval('(' + sniffer + ')'));\\n\"+\n",
"\" }else{\\n\"+\n",
"\" pd_controls.command = addOptions(pd_controls.command, eval('(' + sniffer + ')'));\\n\"+\n",
"\" } \\n\"+\n",
"\" }.bind(this));\\n\"+\n",
"\"\\n\"+\n",
"\" var process_output = getScriptOfType(element, \\\"process_output\\\");\\n\"+\n",
"\" if (!process_output){\\n\"+\n",
"\" process_output = getScriptOfType($(\\\"#\\\" + this.targetDivId), \\\"process_output\\\");\\n\"+\n",
"\" }\\n\"+\n",
"\" if (process_output){\\n\"+\n",
"\" this.process_output = function(output){\\n\"+\n",
"\" new Function('output', process_output)(output);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" if ( this.options.dialog == 'true' ){\\n\"+\n",
"\" pixiedust.executeInDialog(pd_controls, this);\\n\"+\n",
"\" }else{\\n\"+\n",
"\" pixiedust.executeDisplay(pd_controls, this);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" \\n\"+\n",
"\" var refreshTarget = element.getAttribute(\\\"pd_refresh\\\");\\n\"+\n",
"\" if (refreshTarget){\\n\"+\n",
"\" if (execInfo.targetDivId == \\\"pixiedust_dummy\\\"){\\n\"+\n",
"\" \\n\"+\n",
"\" execInfo.targetDivId = \\\"pixiedust_dummy2\\\";\\n\"+\n",
"\" }\\n\"+\n",
"\" var retQueue = [execInfo];\\n\"+\n",
"\" var targets = refreshTarget.split(\\\",\\\");\\n\"+\n",
"\" $.each( targets, function(index){\\n\"+\n",
"\" var node = $(\\\"#\\\" + this);\\n\"+\n",
"\" if (node.length){\\n\"+\n",
"\" pd_controls.refreshTarget = this;\\n\"+\n",
"\" var thisexecInfo = {\\\"options\\\":{}};\\n\"+\n",
"\" thisexecInfo.options.targetDivId = this;\\n\"+\n",
"\" retQueue.push( readExecInfo(pd_controls, node.get(0), false, thisexecInfo) );\\n\"+\n",
"\" }\\n\"+\n",
"\" });\\n\"+\n",
"\" return retQueue\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" console.log(\\\"execution info: \\\", execInfo);\\n\"+\n",
"\" return execInfo;\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\"function runElement(element, searchParents){\\n\"+\n",
"\" var pd_controls = element.getAttribute(\\\"pixiedust\\\");\\n\"+\n",
"\" if (!pd_controls){\\n\"+\n",
"\" $(element).parents(\\\"[pixiedust]\\\").each(function(){\\n\"+\n",
"\" pd_controls = pd_controls || this.getAttribute(\\\"pixiedust\\\");\\n\"+\n",
"\" });\\n\"+\n",
"\" }\\n\"+\n",
"\" var execQueue = [];\\n\"+\n",
"\" function addToQueue(execInfo){\\n\"+\n",
"\" if (Array.isArray(execInfo)){\\n\"+\n",
"\" execInfo.forEach(function(exec){\\n\"+\n",
"\" addToQueue(exec);\\n\"+\n",
"\" });\\n\"+\n",
"\" }else{\\n\"+\n",
"\" execQueue.push(execInfo);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" if (pd_controls){\\n\"+\n",
"\" pd_controls = JSON.parse(pd_controls);\\n\"+\n",
"\" \\n\"+\n",
"\" addToQueue( readExecInfo(pd_controls, element, searchParents) );\\n\"+\n",
"\"\\n\"+\n",
"\" \\n\"+\n",
"\" $(element).children(\\\"target[pd_target]\\\").each(function(){\\n\"+\n",
"\" addToQueue( readExecInfo(pd_controls, this, searchParents))\\n\"+\n",
"\" });\\n\"+\n",
"\" }\\n\"+\n",
"\" return execQueue;\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\"function filterNonTargetElements(element){\\n\"+\n",
"\" if (element && [\\\"I\\\", \\\"DIV\\\"].includes(element.tagName)){\\n\"+\n",
"\" if (!element.hasAttribute(\\\"pd_options\\\") || $(element).find(\\\"> pd_options\\\").length == 0 || element.hasAttribute(\\\"pd_render_onload\\\")){\\n\"+\n",
"\" return filterNonTargetElements(element.parentElement);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" return element;\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\"function readJSONAttribute(element, attrName){\\n\"+\n",
"\" var payload = resolveScriptMacros(element.getAttribute(attrName));\\n\"+\n",
"\" if (payload){\\n\"+\n",
"\" var parts = payload.split(\\\";\\\");\\n\"+\n",
"\" payload = {};\\n\"+\n",
"\" $.each( parts, function(){\\n\"+\n",
"\" var index = this.indexOf(\\\"=\\\");\\n\"+\n",
"\" if ( index > 0){\\n\"+\n",
"\" payload[this.substring(0, index)] = this.substring(index+1);\\n\"+\n",
"\" }\\n\"+\n",
"\" });\\n\"+\n",
"\" }else{\\n\"+\n",
"\" \\n\"+\n",
"\" $(element).find(\\\"> \\\" + attrName).each(function(){\\n\"+\n",
"\" try{\\n\"+\n",
"\" payload = JSON.parse($(this).text());\\n\"+\n",
"\" for (var key in payload) { \\n\"+\n",
"\" payload[key] = resolveScriptMacros(payload[key]); \\n\"+\n",
"\" }\\n\"+\n",
"\" }catch(e){\\n\"+\n",
"\" console.log(\\\"Error parsing \\\" + attrName + \\\", invalid json\\\", e);\\n\"+\n",
"\" }\\n\"+\n",
"\" })\\n\"+\n",
"\" }\\n\"+\n",
"\" return payload;\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\"\\n\"+\n",
"\"function processEvent(event){\\n\"+\n",
"\" if (event.pd_processed){\\n\"+\n",
"\" return;\\n\"+\n",
"\" }\\n\"+\n",
"\" \\n\"+\n",
"\" var payload = readJSONAttribute(event.target, \\\"pd_event_payload\\\");\\n\"+\n",
"\" if (payload){\\n\"+\n",
"\" pixiedust.sendEvent(payload, $(event.target).uniqueId().attr('id'));\\n\"+\n",
"\" }\\n\"+\n",
"\" execQueue = runElement(filterNonTargetElements(event.target));\\n\"+\n",
"\" \\n\"+\n",
"\" $.each( execQueue, function(index, value){\\n\"+\n",
"\" if (value){\\n\"+\n",
"\" event.pd_processed = true;\\n\"+\n",
"\" value.execute();\\n\"+\n",
"\" }\\n\"+\n",
"\" });\\n\"+\n",
"\"}\\n\"+\n",
"\"$(document).on( \\\"click\\\", \\\"[pixiedust]\\\", function(event){\\n\"+\n",
"\" if (event.target.tagName == \\\"SELECT\\\" || \\n\"+\n",
"\" (event.target.tagName == \\\"INPUT\\\" && (getAttribute(event.target, \\\"type\\\", \\\"\\\").toLowerCase() != \\\"button\\\")) || \\n\"+\n",
"\" $(event.target).is(':checkbox')){\\n\"+\n",
"\" return;\\n\"+\n",
"\" }\\n\"+\n",
"\" processEvent(event)\\n\"+\n",
"\"});\\n\"+\n",
"\"\\n\"+\n",
"\"$(document).on( \\\"change\\\", \\\"[pixiedust]\\\", function(event){\\n\"+\n",
"\" processEvent(event)\\n\"+\n",
"\"});\\n\"+\n",
"\"\\n\"+\n",
"\"\\n\"+\n",
"\"$(document).on(\\\"pd_event\\\", function(event, eventInfo){\\n\"+\n",
"\" targetDivId = eventInfo.targetDivId;\\n\"+\n",
"\" if (targetDivId){\\n\"+\n",
"\" eventHandlers = $(\\\"pd_event_handler\\\").filter(function(){\\n\"+\n",
"\" source = this.getAttribute(\\\"pd_source\\\");\\n\"+\n",
"\" if (source == \\\"*\\\" || source == targetDivId || source == eventInfo.type){\\n\"+\n",
"\" return true;\\n\"+\n",
"\" }\\n\"+\n",
"\" \\n\"+\n",
"\" return $(this).parents(\\\"[pd_target]\\\").filter(function(){\\n\"+\n",
"\" return this.getAttribute(\\\"pd_target\\\") == targetDivId;\\n\"+\n",
"\" }).length > 0;\\n\"+\n",
"\" });\\n\"+\n",
"\" eventHandlers.each(function(){\\n\"+\n",
"\" execQueue = runElement(this, false);\\n\"+\n",
"\" $.each( execQueue, function(index, value){\\n\"+\n",
"\" if (value){\\n\"+\n",
"\" if (value.targetDivId == \\\"pixiedust_dummy\\\"){\\n\"+\n",
"\" value.targetDivId = null;\\n\"+\n",
"\" }\\n\"+\n",
"\" \\n\"+\n",
"\" if (value.script){\\n\"+\n",
"\" value.script = \\\"true=True\\\\nfalse=False\\\\neventInfo=\\\"+JSON.stringify(eventInfo) + \\\"\\\\n\\\" + value.script;\\n\"+\n",
"\" }\\n\"+\n",
"\" value.execute();\\n\"+\n",
"\" }\\n\"+\n",
"\" });\\n\"+\n",
"\" });\\n\"+\n",
"\" }else if ( eventInfo.type == \\\"pd_load\\\" && eventInfo.targetNode){\\n\"+\n",
"\" var execQueue = []\\n\"+\n",
"\" function accept(element){\\n\"+\n",
"\" return element.hasAttribute(\\\"pd_widget\\\") || element.hasAttribute(\\\"pd_render_onload\\\") || element.hasAttribute(\\\"pd_refresh_rate\\\");\\n\"+\n",
"\" }\\n\"+\n",
"\" eventInfo.targetNode.find(\\\"div\\\").each(function(){\\n\"+\n",
"\" if (accept(this)){\\n\"+\n",
"\" var thisId = $(this).uniqueId().attr('id');\\n\"+\n",
"\" this.setAttribute( \\\"id\\\", thisId );\\n\"+\n",
"\" if (!this.hasAttribute(\\\"pd_target\\\") ){\\n\"+\n",
"\" this.setAttribute(\\\"pd_target\\\", this.getAttribute(\\\"id\\\") );\\n\"+\n",
"\" }\\n\"+\n",
"\" thisQueue = runElement(this, false);\\n\"+\n",
"\" var loadingDiv = this;\\n\"+\n",
"\" $.each( thisQueue, function(index, value){\\n\"+\n",
"\" if (value){\\n\"+\n",
"\" value.partialUpdate = true;\\n\"+\n",
"\" execQueue.push( value );\\n\"+\n",
"\" refreshRate = loadingDiv.getAttribute(\\\"pd_refresh_rate\\\");\\n\"+\n",
"\" if (refreshRate){\\n\"+\n",
"\" var ival = setInterval(function(){\\n\"+\n",
"\" if ($('#' + thisId).length == 0){\\n\"+\n",
"\" console.log(\\\"Clearing refresh timer\\\", ival);\\n\"+\n",
"\" clearInterval(ival);\\n\"+\n",
"\" return;\\n\"+\n",
"\" }\\n\"+\n",
"\" value.execute();\\n\"+\n",
"\" }, parseInt( refreshRate) );\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" })\\n\"+\n",
"\" }\\n\"+\n",
"\" });\\n\"+\n",
"\"\\n\"+\n",
"\" \\n\"+\n",
"\" $.each( execQueue, function(index, value){\\n\"+\n",
"\" value.execute();\\n\"+\n",
"\" });\\n\"+\n",
"\" }\\n\"+\n",
"\" else{\\n\"+\n",
"\" if ( eventInfo.type != \\\"pd_load\\\"){\\n\"+\n",
"\" console.log(\\\"Warning: got a pd_event with no targetDivId\\\", eventInfo);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\"});\";\n",
" try{\n",
" g.appendChild(document.createTextNode(code));\n",
" }catch(e){\n",
" g.text = code;\n",
" }\n",
" s.parentNode.insertBefore(g,s);\n",
"}"
],
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<script>\n",
" //Marker 887a9ef0\n",
" setTimeout(function(){\n",
" var cells=IPython.notebook.get_cells().filter(function(cell){\n",
" if(!cell.output_area || !cell.output_area.outputs){\n",
" return false;\n",
" }\n",
" return cell.output_area.outputs.filter(function(output){\n",
" if (output.output_type===\"display_data\"&&output.data&&output.data[\"text/html\"]){\n",
" return output.data[\"text/html\"].includes(\"//Marker 887a9ef0\")\n",
" }\n",
" return false;\n",
" }).length > 0;\n",
" });\n",
" if(cells.length>0){\n",
" var cell=cells[0];\n",
" var cellId=cell.cell_id;\n",
" var cellMetadata=cell._metadata.pixiedust;\n",
" var old_msg_id = cell.last_msg_id;\n",
" if (old_msg_id) {\n",
" cell.kernel.clear_callbacks_for_msg(old_msg_id);\n",
" }\n",
" function getCellWidth(){\n",
" try{\n",
" return cell.input[0].clientWidth\n",
" }catch(e){\n",
" console.log(e)\n",
" }\n",
" }\n",
" function getViewportHeight(){\n",
" try {\n",
" return document.documentElement.clientHeight\n",
" } catch(e) {\n",
" console.log(e)\n",
" }\n",
" }\n",
" var snifferOptions = [{'nostore_cw':getCellWidth()},{'nostore_vh':getViewportHeight()},{'nostore_pixiedust':(typeof pixiedust != \"undefined\")}];\n",
" \n",
" snifferOptions.push({'org_params':'nostore_pixiedust'});\n",
" \n",
" \n",
" snifferOptions.push({'nostore_bokeh':!!window.Bokeh})\n",
" \n",
" user_options = { 'options': {\n",
" 'nostore_cw':getCellWidth(),\n",
" 'nostore_vh':getViewportHeight(),\n",
" 'nostore_pixiedust':(typeof pixiedust != \"undefined\"),\n",
" 'showchrome': 'true',\n",
" 'cell_id': cellId\n",
" }}\n",
" \n",
" user_options.options.org_params= 'nostore_pixiedust';\n",
" \n",
" \n",
" user_options.options = $.extend({}, user_options.options, {'nostore_bokeh':!!window.Bokeh} );\n",
" \n",
"\n",
" function callback(){\n",
" pixiedust.executeDisplay({\"prefix\": \"887a9ef0\", \"command\": \"display(pdf,cell_id='cellId',nostore_pixiedust='true')\", \"entity\": \"pdf\", \"options\": {\"cell_id\": \"cellId\", \"nostore_pixiedust\": \"true\"}, \"sniffers\": [\"{'nostore_bokeh':!!window.Bokeh}\"], \"avoidMetadata\": false, \"include_keys\": [\"filter\"]},user_options);\n",
" }\n",
" if (typeof pixiedust == \"undefined\"){\n",
" var s=document.getElementsByTagName('script')[0];\n",
" var g=document.createElement('script');\n",
" g.type='text/javascript';\n",
" g.defer=true; \n",
" g.async=true;\n",
" var code = \"var pixiedust = (function(){\\n\"+\n",
"\" return {\\n\"+\n",
"\" input_reply_queue: {\\n\"+\n",
"\" inflight: null,\\n\"+\n",
"\" queue: [],\\n\"+\n",
"\" callbacks: {},\\n\"+\n",
"\" counter: 0,\\n\"+\n",
"\" registerCallback: function(cb){\\n\"+\n",
"\" var handle = 'id_' + this.counter++;\\n\"+\n",
"\" this.callbacks[handle] = cb;\\n\"+\n",
"\" return \\\"$$\\\" + handle + \\\"$$\\\";\\n\"+\n",
"\" },\\n\"+\n",
"\" parseCallback: function(content){\\n\"+\n",
"\" var match = content.text.match(/\\\\$\\\\$(.*)\\\\$\\\\$((.|\\\\n)*)/i);\\n\"+\n",
"\" if (match){\\n\"+\n",
"\" content.text = match[2].trim();\\n\"+\n",
"\" if (!this.callbacks[match[1]]){\\n\"+\n",
"\" console.log(\\\"Cannot find callbacks for \\\" + match[1]);\\n\"+\n",
"\" }else{\\n\"+\n",
"\" var retValue = this.callbacks[match[1]];\\n\"+\n",
"\" delete this.callbacks[match[1]];\\n\"+\n",
"\" return retValue;\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" return null;\\n\"+\n",
"\" }\\n\"+\n",
"\" },\\n\"+\n",
"\" getCell: function(cell_id){\\n\"+\n",
"\" \\n\"+\n",
"\" var cells=IPython.notebook.get_cells().filter(function(cell){\\n\"+\n",
"\" return cell.cell_id==cell_id;\\n\"+\n",
"\" });\\n\"+\n",
"\" \\n\"+\n",
"\" return cells.length>0?cells[0]:null;\\n\"+\n",
"\" },\\n\"+\n",
"\" \\n\"+\n",
"\" executeDisplay:function(pd_ctls, user_ctls){\\n\"+\n",
"\" var pd_controls = pd_ctls || {};\\n\"+\n",
"\" var user_controls = user_ctls || {\\\"options\\\":{}};\\n\"+\n",
"\" if (user_controls.inFlight){\\n\"+\n",
"\" console.log(\\\"Ignoring request to execute Display that is already being executed\\\");\\n\"+\n",
"\" return;\\n\"+\n",
"\" }\\n\"+\n",
"\" user_controls.inFlight = true;\\n\"+\n",
"\" var options = $.extend({}, pd_controls.options || {}, user_controls.options || {} );\\n\"+\n",
"\" function wrapDisplayDone(fn){\\n\"+\n",
"\" return function(targetNode, targetNodeUpdated){\\n\"+\n",
"\" user_controls.inFlight = false;\\n\"+\n",
"\" if(targetNodeUpdated){\\n\"+\n",
"\" if (fn){\\n\"+\n",
"\" fn.apply(this);\\n\"+\n",
"\" }\\n\"+\n",
"\" $(document).trigger('pd_event', {type:\\\"pd_load\\\", targetNode: targetNode});\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" user_controls.onDisplayDone = wrapDisplayDone( user_controls.onDisplayDone);\\n\"+\n",
"\" var pd_prefix = pd_controls.prefix;\\n\"+\n",
"\" var $targetDivId = user_controls.targetDivId;\\n\"+\n",
"\" !function() {\\n\"+\n",
"\" function getTargetNodeId(override=null){\\n\"+\n",
"\" return override || $targetDivId || (\\\"wrapperHTML\\\"+ pd_prefix);\\n\"+\n",
"\" }\\n\"+\n",
"\" function getTargetNode(override=null){\\n\"+\n",
"\" return $('#' + getTargetNodeId(override));\\n\"+\n",
"\" }\\n\"+\n",
"\" function checkRootInit(){\\n\"+\n",
"\" node = getTargetNode();\\n\"+\n",
"\" var retValue = node.is(\\\"[pd_init]\\\");\\n\"+\n",
"\" if (retValue){\\n\"+\n",
"\" node.removeAttr(\\\"pd_init\\\");\\n\"+\n",
"\" }\\n\"+\n",
"\" return retValue;\\n\"+\n",
"\" }\\n\"+\n",
"\" function setText(targetNode, contents, pdCtl = null, userCtl = null){\\n\"+\n",
"\" var pd_elements = []\\n\"+\n",
"\" targetNode.children().each(function(){\\n\"+\n",
"\" if (this.tagName.toLowerCase().startsWith(\\\"pd_\\\")){\\n\"+\n",
"\" pd_elements.push($(this).clone());\\n\"+\n",
"\" }\\n\"+\n",
"\" });\\n\"+\n",
"\" if (!targetNode.hasClass(\\\"use_stream_output\\\")){\\n\"+\n",
"\" targetNode.text(contents);\\n\"+\n",
"\" }else{\\n\"+\n",
"\" var consoleNode = targetNode.children(\\\"div.consoleOutput\\\");\\n\"+\n",
"\" if (consoleNode.length == 0){\\n\"+\n",
"\" consoleNode = targetNode.append('<div class=\\\"consoleOutput\\\"></div>').children(\\\"div.consoleOutput\\\");\\n\"+\n",
"\" }\\n\"+\n",
"\" var existing = consoleNode.text();\\n\"+\n",
"\" if (existing != \\\"\\\"){\\n\"+\n",
"\" contents = existing + \\\"\\\\n\\\" + contents;\\n\"+\n",
"\" }\\n\"+\n",
"\" consoleNode.html('<pre style=\\\"max-height: 300px;border: 1px lightgray solid;margin-top: 20px;\\\">' + contents + \\\"</pre>\\\");\\n\"+\n",
"\" }\\n\"+\n",
"\" if (pd_elements.length > 0 ){\\n\"+\n",
"\" targetNode.append(pd_elements);\\n\"+\n",
"\" }\\n\"+\n",
"\" return true;\\n\"+\n",
"\" }\\n\"+\n",
"\" function setHTML(targetNode, contents, pdCtl = null, userCtl = null){\\n\"+\n",
"\" var pd_elements = []\\n\"+\n",
"\" targetNode.children().each(function(){\\n\"+\n",
"\" var eltName = this.tagName.toLowerCase();\\n\"+\n",
"\" if (eltName.startsWith(\\\"pd_\\\") || (eltName == \\\"div\\\" && this.classList.contains(\\\"consoleOutput\\\")) ){\\n\"+\n",
"\" pd_elements.push($(this).clone());\\n\"+\n",
"\" }\\n\"+\n",
"\" });\\n\"+\n",
"\" targetNode.html(\\\"<div pd_stop_propagation style='height:100%;'>\\\" + contents + \\\"</div>\\\");\\n\"+\n",
"\" if (pd_elements.length > 0 ){\\n\"+\n",
"\" targetNode.append(pd_elements);\\n\"+\n",
"\" }\\n\"+\n",
"\" return true;\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" function send_input_reply(cb, cmd, pd_controls){\\n\"+\n",
"\" if (cmd == 'c' || cmd == 'continue' || cmd == 'q' || cmd == 'quit' || cmd.startsWith(\\\"$$\\\")){\\n\"+\n",
"\" cb = null;\\n\"+\n",
"\" pixiedust.input_reply_queue.queue = [];\\n\"+\n",
"\" pixiedust.input_reply_queue.callbacks = {};\\n\"+\n",
"\" $(\\\"#debugger_container_\\\" + pd_controls.prefix).hide();\\n\"+\n",
"\" if (cmd.startsWith(\\\"$$\\\")){\\n\"+\n",
"\" cmd = cmd.substring(2);\\n\"+\n",
"\" }\\n\"+\n",
"\" }else if (cmd == 'no_op'){\\n\"+\n",
"\" cb = null;\\n\"+\n",
"\" cmd = null;\\n\"+\n",
"\" }\\n\"+\n",
"\" if (cb && $targetDivId == \\\"debugger_refresh\\\"){\\n\"+\n",
"\" cb.refreshDebugger = true;\\n\"+\n",
"\" }\\n\"+\n",
"\" pixiedust.input_reply_queue.inflight = cb;\\n\"+\n",
"\" if (cmd){\\n\"+\n",
"\" var prolog = cb ? \\\"print('\\\" + pixiedust.input_reply_queue.registerCallback(cb) + \\\"');;\\\" : \\\"\\\";\\n\"+\n",
"\" IPython.notebook.session.kernel.send_input_reply( prolog + cmd );\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" var cellId = options.cell_id || \\\"\\\";\\n\"+\n",
"\" var curCell = pixiedust.getCell(cellId);\\n\"+\n",
"\" console.log(\\\"curCell\\\",curCell);\\n\"+\n",
"\" \\n\"+\n",
"\" var callbacks = {\\n\"+\n",
"\" shell : {\\n\"+\n",
"\" reply : function(){\\n\"+\n",
"\" if ( !callbacks.response ){\\n\"+\n",
"\" var targetNodeUpdated = false;\\n\"+\n",
"\" if (!user_controls.partialUpdate){\\n\"+\n",
"\" targetNodeUpdated = setHTML(getTargetNode(), \\\"\\\",pd_controls, user_controls);\\n\"+\n",
"\" }\\n\"+\n",
"\" if (user_controls.onDisplayDone){\\n\"+\n",
"\" user_controls.onDisplayDone(getTargetNode(), targetNodeUpdated);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" },\\n\"+\n",
"\" payload : {\\n\"+\n",
"\" set_next_input : function(payload){\\n\"+\n",
"\" if (curCell){\\n\"+\n",
"\" curCell._handle_set_next_input(payload);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" },\\n\"+\n",
"\" iopub:{\\n\"+\n",
"\" output:function(msg){\\n\"+\n",
"\" if (curCell && !$targetDivId && getTargetNode().length == 0){\\n\"+\n",
"\" curCell.output_area.handle_output.apply(curCell.output_area, arguments);\\n\"+\n",
"\" return;\\n\"+\n",
"\" }\\n\"+\n",
"\" callbacks.response = true;\\n\"+\n",
"\" console.log(\\\"msg\\\", msg);\\n\"+\n",
"\" \\n\"+\n",
"\" if (cellId == \\\"\\\"){\\n\"+\n",
"\" if (curCell){\\n\"+\n",
"\" curCell.output_area.handle_output.apply(curCell.output_area, arguments);\\n\"+\n",
"\" curCell.output_area.outputs=[];\\n\"+\n",
"\" }else{\\n\"+\n",
"\" console.log(\\\"Could not find current cell\\\");\\n\"+\n",
"\" }\\n\"+\n",
"\" return;\\n\"+\n",
"\" }\\n\"+\n",
"\" \\n\"+\n",
"\" var msg_type=msg.header.msg_type;\\n\"+\n",
"\" var content = msg.content;\\n\"+\n",
"\" var targetNodeUpdated = false;\\n\"+\n",
"\" if(msg_type===\\\"stream\\\"){\\n\"+\n",
"\" var reply_callbacks = pixiedust.input_reply_queue.parseCallback(content);\\n\"+\n",
"\" if (reply_callbacks && reply_callbacks != callbacks){\\n\"+\n",
"\" if (reply_callbacks.iopub){\\n\"+\n",
"\" reply_callbacks.iopub.output(msg);\\n\"+\n",
"\" }\\n\"+\n",
"\" return;\\n\"+\n",
"\" }\\n\"+\n",
"\" var useHTML = false;\\n\"+\n",
"\" var process_output = getScriptOfType($(\\\"#\\\" + $targetDivId), \\\"process_output\\\");\\n\"+\n",
"\" if (process_output){\\n\"+\n",
"\" try{\\n\"+\n",
"\" content.text = new Function('output', process_output)(content.text);\\n\"+\n",
"\" useHTML = true;\\n\"+\n",
"\" }catch(e){\\n\"+\n",
"\" console.log(\\\"Error while invoking post output function\\\", e, content.text, process_output);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" if (user_controls.onSuccess){\\n\"+\n",
"\" user_controls.onSuccess(content.text);\\n\"+\n",
"\" }else{\\n\"+\n",
"\" fn = useHTML?setHTML:setText;\\n\"+\n",
"\" targetNodeUpdated = fn(getTargetNode(), content.text, pd_controls, user_controls);\\n\"+\n",
"\" }\\n\"+\n",
"\" }else if (msg_type===\\\"display_data\\\" || msg_type===\\\"execute_result\\\"){\\n\"+\n",
"\" var html=null;\\n\"+\n",
"\" if (!!content.data[\\\"text/html\\\"]){\\n\"+\n",
"\" html=content.data[\\\"text/html\\\"];\\n\"+\n",
"\" }else if (!!content.data[\\\"image/png\\\"]){\\n\"+\n",
"\" html=html||\\\"\\\";\\n\"+\n",
"\" html+=\\\"<img src='data:image/png;base64,\\\" +content.data[\\\"image/png\\\"]+\\\"'></img>\\\";\\n\"+\n",
"\" }\\n\"+\n",
"\" \\n\"+\n",
"\" if (!!content.data[\\\"application/javascript\\\"]){\\n\"+\n",
"\" try {\\n\"+\n",
"\" eval(content.data[\\\"application/javascript\\\"]);\\n\"+\n",
"\" } catch(err) {\\n\"+\n",
"\" curCell.output_area.handle_output.apply(curCell.output_area, arguments);\\n\"+\n",
"\" } \\n\"+\n",
"\" return;\\n\"+\n",
"\" }\\n\"+\n",
"\" \\n\"+\n",
"\" if (html){\\n\"+\n",
"\" try{\\n\"+\n",
"\" if (user_controls.onSuccess){\\n\"+\n",
"\" user_controls.onSuccess(html);\\n\"+\n",
"\" }else{\\n\"+\n",
"\" targetNodeUpdated = setHTML(getTargetNode(), html, pd_controls, user_controls);\\n\"+\n",
"\" }\\n\"+\n",
"\" if (content.metadata && content.metadata.pixieapp_metadata){\\n\"+\n",
"\" \\n\"+\n",
"\" if (curCell){\\n\"+\n",
"\" curCell._metadata.pixiedust.pixieapp = content.metadata.pixieapp_metadata;\\n\"+\n",
"\" }\\n\"+\n",
"\" \\n\"+\n",
"\" } \\n\"+\n",
"\" }catch(e){\\n\"+\n",
"\" console.log(\\\"Invalid html output\\\", e, html);\\n\"+\n",
"\" targetNodeUpdated = setHTML(getTargetNode(), \\\"Invalid html output: \\\" + e.message + \\\"<pre>\\\" \\n\"+\n",
"\" + html.replace(/>/g,'&gt;').replace(/</g,'&lt;').replace(/\\\"/g,'&quot;') + \\\"<pre>\\\",\\n\"+\n",
"\" pd_controls, user_controls);\\n\"+\n",
"\" }\\n\"+\n",
"\" if (callbacks.options && callbacks.options.nostore_delaysave){\\n\"+\n",
"\" setTimeout(function(){\\n\"+\n",
"\" pixiedust.saveOutputInCell(curCell, content, html, msg_type);\\n\"+\n",
"\" }, 1000);\\n\"+\n",
"\" }else{\\n\"+\n",
"\" pixiedust.saveOutputInCell(curCell, content, html, msg_type);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" }else if (msg_type === \\\"error\\\") {\\n\"+\n",
"\" \\n\"+\n",
"\" require(['base/js/utils'], function(utils) {\\n\"+\n",
"\" if (content.ename == \\\"BdbQuit\\\"){\\n\"+\n",
"\" targetNodeUpdated = setHTML(\\n\"+\n",
"\" getTargetNode(), \\n\"+\n",
"\" \\\"PixieDebugger exited\\\", \\n\"+\n",
"\" pd_controls, \\n\"+\n",
"\" user_controls\\n\"+\n",
"\" );\\n\"+\n",
"\" }else{\\n\"+\n",
"\" var tb = content.traceback;\\n\"+\n",
"\" console.log(\\\"tb\\\",tb);\\n\"+\n",
"\" if (tb && tb.length>0){\\n\"+\n",
"\" var data = tb.reduce(function(res, frame){return res+frame+'\\\\\\\\n';},\\\"\\\");\\n\"+\n",
"\" console.log(\\\"data\\\",data);\\n\"+\n",
"\" data = utils.fixConsole(data);\\n\"+\n",
"\" data = utils.fixCarriageReturn(data);\\n\"+\n",
"\" data = utils.autoLinkUrls(data);\\n\"+\n",
"\" if (user_controls.onError){\\n\"+\n",
"\" user_controls.onError(data);\\n\"+\n",
"\" }else{\\n\"+\n",
"\" var debugger_html = '<button type=\\\"submit\\\" pd_options=\\\"new_parent_prefix=false\\\" pd_target=\\\"' + \\n\"+\n",
"\" getTargetNodeId() + '\\\" pd_app=\\\"pixiedust.apps.debugger.PixieDebugger\\\">Post Mortem</button>' +\\n\"+\n",
"\" '<span>&nbsp;&nbsp;</span>' +\\n\"+\n",
"\" '<button type=\\\"submit\\\" pd_options=\\\"new_parent_prefix=false;debug_route=true\\\" pd_target=\\\"' + \\n\"+\n",
"\" getTargetNodeId() + '\\\" pd_app=\\\"pixiedust.apps.debugger.PixieDebugger\\\">Debug Route</button>'\\n\"+\n",
"\"\\n\"+\n",
"\" targetNodeUpdated = setHTML(\\n\"+\n",
"\" getTargetNode(), \\n\"+\n",
"\" debugger_html + \\\"<pre>\\\" + data + '</pre>' + debugger_html, \\n\"+\n",
"\" pd_controls, \\n\"+\n",
"\" user_controls\\n\"+\n",
"\" );\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" });\\n\"+\n",
"\" \\n\"+\n",
"\" }else{\\n\"+\n",
"\" callbacks.response = false;\\n\"+\n",
"\" }\\n\"+\n",
"\" if (user_controls.onDisplayDone){\\n\"+\n",
"\" user_controls.onDisplayDone(getTargetNode(), targetNodeUpdated);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" },\\n\"+\n",
"\" input : function(msg){\\n\"+\n",
"\" var reply_callbacks = pixiedust.input_reply_queue.inflight;\\n\"+\n",
"\" if (!reply_callbacks || reply_callbacks.refreshDebugger){\\n\"+\n",
"\" $(\\\"#debugger_container_\\\" + pd_controls.prefix).show();\\n\"+\n",
"\" var input_target = \\\"input_reply_\\\" + pd_controls.prefix;\\n\"+\n",
"\" var process_output = getScriptOfType($(\\\"#\\\" + input_target), \\\"process_output\\\");\\n\"+\n",
"\" if (process_output){\\n\"+\n",
"\" try{\\n\"+\n",
"\" if (reply_callbacks){\\n\"+\n",
"\" reply_callbacks.refreshDebugger = false;\\n\"+\n",
"\" }\\n\"+\n",
"\" if (!pixiedust.input_reply_queue.inflight){\\n\"+\n",
"\" pixiedust.input_reply_queue.inflight = {};\\n\"+\n",
"\" }\\n\"+\n",
"\" msg.content.prompt = new Function('output', process_output)(msg.content.prompt);\\n\"+\n",
"\" targetNodeUpdated = setHTML(getTargetNode(input_target), msg.content.prompt, pd_controls, user_controls);\\n\"+\n",
"\" if (user_controls.onDisplayDone){\\n\"+\n",
"\" user_controls.onDisplayDone(getTargetNode(input_target), targetNodeUpdated);\\n\"+\n",
"\" }\\n\"+\n",
"\" }catch(e){\\n\"+\n",
"\" console.log(\\\"Error while invoking post output function\\\", e, msg.content.prompt, process_output);\\n\"+\n",
"\" }\\n\"+\n",
"\" }else{\\n\"+\n",
"\" console.log(\\\"No element with id input_reply_\\\"+pd_controls.prefix + \\\" found\\\");\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" if (reply_callbacks && reply_callbacks.answer_input_reply){\\n\"+\n",
"\" var answer = reply_callbacks.answer_input_reply;\\n\"+\n",
"\" reply_callbacks.answer_input_reply = null;\\n\"+\n",
"\" send_input_reply(reply_callbacks, answer, pd_controls);\\n\"+\n",
"\" }else{\\n\"+\n",
"\" var next_input_reply = pixiedust.input_reply_queue.queue.shift();\\n\"+\n",
"\" if (next_input_reply && next_input_reply.command == \\\"no_op_delay\\\"){\\n\"+\n",
"\" next_input_reply = pixiedust.input_reply_queue.queue.shift();\\n\"+\n",
"\" }\\n\"+\n",
"\" if (next_input_reply){\\n\"+\n",
"\" send_input_reply(next_input_reply.callbacks, next_input_reply.command, pd_controls);\\n\"+\n",
"\" }else{\\n\"+\n",
"\" pixiedust.input_reply_queue.inflight = null;\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" console.log(\\\"Handling input msg request: \\\", msg);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" \\n\"+\n",
"\" if (IPython && IPython.notebook && IPython.notebook.session && IPython.notebook.session.kernel){\\n\"+\n",
"\" \\n\"+\n",
"\" var command = user_controls.script || pd_controls.command.replace(\\\"cellId\\\",cellId);\\n\"+\n",
"\" if ( !user_controls.script){\\n\"+\n",
"\" function addOptions(options, override=true, ignoreKeys=[]){\\n\"+\n",
"\" function getStringRep(v) {\\n\"+\n",
"\" return \\\"'\\\" + v + \\\"'\\\";\\n\"+\n",
"\" }\\n\"+\n",
"\" for (var key in (options||{})){\\n\"+\n",
"\" if (ignoreKeys.indexOf(key)>=0){\\n\"+\n",
"\" continue;\\n\"+\n",
"\" }\\n\"+\n",
"\" var value = options[key];\\n\"+\n",
"\" var hasValue = value != null && typeof value !== 'undefined' && value !== '';\\n\"+\n",
"\" var replaceValue = hasValue ? (key+\\\"=\\\" + getStringRep(value) ) : \\\"\\\";\\n\"+\n",
"\" var pattern = (hasValue?\\\"\\\":\\\",\\\")+\\\"\\\\\\\\s*\\\" + key + \\\"\\\\\\\\s*=\\\\\\\\s*'(\\\\\\\\\\\\\\\\'|[^'])*'\\\";\\n\"+\n",
"\" var rpattern=new RegExp(pattern);\\n\"+\n",
"\" var n = command.search(rpattern);\\n\"+\n",
"\" if ( n >= 0 ){\\n\"+\n",
"\" if (override){\\n\"+\n",
"\" command = command.replace(rpattern, replaceValue);\\n\"+\n",
"\" }\\n\"+\n",
"\" }else if (hasValue){\\n\"+\n",
"\" var n = command.lastIndexOf(\\\")\\\");\\n\"+\n",
"\" command = [command.slice(0, n), (command[n-1]==\\\"(\\\"? \\\"\\\":\\\",\\\") + replaceValue, command.slice(n)].join('')\\n\"+\n",
"\" } \\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" if(typeof cellMetadata != \\\"undefined\\\" && cellMetadata.displayParams){\\n\"+\n",
"\" addOptions(cellMetadata.displayParams);\\n\"+\n",
"\" addOptions({\\\"showchrome\\\":\\\"true\\\"});\\n\"+\n",
"\" }else if (curCell && curCell._metadata.pixiedust ){\\n\"+\n",
"\" if (!pd_controls.avoidMetadata){\\n\"+\n",
"\" ignoreKeys = pd_controls.options.nostore_pixieapp?[\\\"handlerId\\\"]:[];\\n\"+\n",
"\" if (pd_controls.override_keys){\\n\"+\n",
"\" Array.prototype.push.apply(ignoreKeys,pd_controls.override_keys);\\n\"+\n",
"\" }\\n\"+\n",
"\" pd_controls.include_keys || []\\n\"+\n",
"\" addOptions(curCell._metadata.pixiedust.displayParams || {}, pd_controls.useCellMetadata, ignoreKeys);\\n\"+\n",
"\" }else{\\n\"+\n",
"\" \\n\"+\n",
"\" var includeKeys = pd_controls.include_keys || [];\\n\"+\n",
"\" var includeOptions = {};\\n\"+\n",
"\" for (var key in (curCell._metadata.pixiedust.displayParams||{})){\\n\"+\n",
"\" if (includeKeys.indexOf(key) > -1 || !(key in pd_controls.options)){\\n\"+\n",
"\" includeOptions[key] = curCell._metadata.pixiedust.displayParams[key];\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" addOptions(includeOptions);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" addOptions(user_controls.options||{});\\n\"+\n",
"\" var pattern = \\\"\\\\\\\\w*\\\\\\\\s*=\\\\\\\\s*'(\\\\\\\\\\\\\\\\'|[^'])*'\\\";\\n\"+\n",
"\" var rpattern=new RegExp(pattern,\\\"g\\\");\\n\"+\n",
"\" var n = command.match(rpattern);\\n\"+\n",
"\" \\n\"+\n",
"\" var org_params = {}\\n\"+\n",
"\" for (var i=0; i<n.length;i++){\\n\"+\n",
"\" var parts = n[i].split(\\\"=\\\")\\n\"+\n",
"\" if (parts[0].trim() == \\\"org_params\\\"){\\n\"+\n",
"\" var value = parts[1].trim()\\n\"+\n",
"\" var values = value.substring(1,value.length-1).split(\\\",\\\");\\n\"+\n",
"\" for (var p in values){\\n\"+\n",
"\" org_params[values[p].trim()] = true;\\n\"+\n",
"\" }\\n\"+\n",
"\" break;\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" var displayParams={}\\n\"+\n",
"\" for (var i = 0; i < n.length; i++){\\n\"+\n",
"\" var parts=n[i].split(\\\"=\\\");\\n\"+\n",
"\" var key = parts[0].trim();\\n\"+\n",
"\" var value = parts[1].trim()\\n\"+\n",
"\" if (!key.startsWith(\\\"nostore_\\\") && key != \\\"showchrome\\\" && key != \\\"prefix\\\" && key != \\\"cell_id\\\" && key != \\\"org_params\\\" && !!!org_params[key]){\\n\"+\n",
"\" displayParams[key] = value.substring(1,value.length-1);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" \\n\"+\n",
"\"\\n\"+\n",
"\" \\n\"+\n",
"\" var rpattern=/,(.*?)='(.*?)'/g;\\n\"+\n",
"\" var newOptions = {};\\n\"+\n",
"\" for (var match = rpattern.exec(command); match != null; match = rpattern.exec(command)){\\n\"+\n",
"\" newOptions[match[1]] = match[2];\\n\"+\n",
"\" }\\n\"+\n",
"\" pd_controls.options = newOptions;\\n\"+\n",
"\" pd_controls.command = command;\\n\"+\n",
"\" }\\n\"+\n",
"\" if(curCell&&curCell.output_area){ \\n\"+\n",
"\" if ( !user_controls.nostoreMedatadata ){\\n\"+\n",
"\" curCell._metadata.pixiedust = curCell._metadata.pixiedust || {}\\n\"+\n",
"\" curCell._metadata.pixiedust.displayParams=displayParams\\n\"+\n",
"\" curCell.output_area.outputs=[];\\n\"+\n",
"\" var old_msg_id = curCell.last_msg_id;\\n\"+\n",
"\" if (old_msg_id) {\\n\"+\n",
"\" curCell.kernel.clear_callbacks_for_msg(old_msg_id);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" }else{\\n\"+\n",
"\" console.log(\\\"couldn't find the cell\\\");\\n\"+\n",
"\" }\\n\"+\n",
"\" $('#wrapperJS' + pd_prefix).html(\\\"\\\")\\n\"+\n",
"\" if (!getTargetNode().hasClass( \\\"no_loading_msg\\\" )){\\n\"+\n",
"\" setHTML(getTargetNode(), \\n\"+\n",
"\" '<div style=\\\"width:100px;height:60px;left:47%;position:relative\\\">'+\\n\"+\n",
"\" '<i class=\\\"fa fa-circle-o-notch fa-spin\\\" style=\\\"font-size:48px\\\"></i>'+\\n\"+\n",
"\" '</div>'+\\n\"+\n",
"\" '<div style=\\\"text-align:center\\\">' +\\n\"+\n",
"\" (getTargetNode().attr(\\\"pd_loading_msg\\\") || \\\"Loading your data. Please wait...\\\") +\\n\"+\n",
"\" '</div>',\\n\"+\n",
"\" pd_controls, user_controls\\n\"+\n",
"\" );\\n\"+\n",
"\" }\\n\"+\n",
"\" \\n\"+\n",
"\" if (curCell && checkRootInit() && curCell._metadata.pixiedust && curCell._metadata.pixiedust.pixieapp){\\n\"+\n",
"\" pd_controls.entity = pd_controls.entity || []\\n\"+\n",
"\" if (pd_controls.entity.length == 1 && (pd_controls.options.nostore_pixieapp == pd_controls.entity[0])){\\n\"+\n",
"\" console.log(\\\"Initializing pixieapp metadata\\\");\\n\"+\n",
"\" command = pd_controls.options.nostore_pixieapp + \\\".append_metadata(\\\" + \\n\"+\n",
"\" JSON.stringify(curCell._metadata.pixiedust.pixieapp) + \\\")\\\\n\\\" + command\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" if (user_controls.send_input_reply){\\n\"+\n",
"\" command = user_controls.send_input_reply;\\n\"+\n",
"\" callbacks.answer_input_reply = user_controls.answer_input_reply;\\n\"+\n",
"\" \\n\"+\n",
"\" pixiedust.input_reply_queue.queue = pixiedust.input_reply_queue.queue.filter(\\n\"+\n",
"\" function(item){\\n\"+\n",
"\" return item.command!='no_op';\\n\"+\n",
"\" }\\n\"+\n",
"\" );\\n\"+\n",
"\" if (pixiedust.input_reply_queue.inflight || pixiedust.input_reply_queue.queue.length > 0 || command == \\\"no_op_delay\\\"){\\n\"+\n",
"\" pixiedust.input_reply_queue.queue.push({\\\"command\\\":command, \\\"callbacks\\\":callbacks});\\n\"+\n",
"\" }else{\\n\"+\n",
"\" send_input_reply(callbacks, command, pd_controls);\\n\"+\n",
"\" }\\n\"+\n",
"\" }else{\\n\"+\n",
"\" if (pixiedust.input_reply_queue.inflight){\\n\"+\n",
"\" console.log(\\\"Warning: A kernel request is triggered but not all the reply callback where consummed\\\", command);\\n\"+\n",
"\" }\\n\"+\n",
"\" command = command.trim();\\n\"+\n",
"\" IPython.notebook.session.kernel.execute(command, callbacks, {\\n\"+\n",
"\" silent:true,store_history:false,stop_on_error:true,allow_stdin : true\\n\"+\n",
"\" });\\n\"+\n",
"\" }\\n\"+\n",
"\" \\n\"+\n",
"\"\\n\"+\n",
"\" console.log(\\\"Running command2:\\\\n\\\",command);\\n\"+\n",
"\" }\\n\"+\n",
"\"}()\\n\"+\n",
"\" },\\n\"+\n",
"\" executeInDialog:function(pd_controls, user_controls){\\n\"+\n",
"\" pd_controls = pd_controls || {};\\n\"+\n",
"\" user_controls = user_controls || {\\\"options\\\":{}};\\n\"+\n",
"\" var displayOptions = $.extend({}, pd_controls.options || {}, user_controls.options || {} );\\n\"+\n",
"\" var global={};\\n\"+\n",
"\" var sourceDivId = displayOptions.targetDivId;\\n\"+\n",
"\" require(['base/js/dialog'],function(dialog){\\n\"+\n",
"\" var modal = dialog.modal;\\n\"+\n",
"\" var attr_pd_ctrl = JSON.stringify(pd_controls).trim()\\n\"+\n",
"\" .replace(/&/g, '&amp;')\\n\"+\n",
"\" .replace(/'/g, '&apos;')\\n\"+\n",
"\" .replace(/\\\"/g, '&quot;')\\n\"+\n",
"\" .replace(/</g, '&lt;')\\n\"+\n",
"\" .replace(/>/g, '&gt;');\\n\"+\n",
"\" var dialogRoot = \\\"dialog\\\" + pd_controls.prefix + \\\"root\\\";\\n\"+\n",
"\" var options = {\\n\"+\n",
"\" title: \\\"PixieDust: \\\" + (displayOptions.title || \\\"Dialog\\\"),\\n\"+\n",
"\" body: '<div id=\\\"' + dialogRoot + '\\\" pixiedust=\\\"' + attr_pd_ctrl + '\\\" class=\\\"pixiedust\\\"></div>',\\n\"+\n",
"\" sanitize:false,\\n\"+\n",
"\" notebook: IPython.notebook,\\n\"+\n",
"\" keyboard_manager: IPython.notebook.keyboard_manager,\\n\"+\n",
"\" maximize_modal: (displayOptions.maximize === \\\"true\\\"),\\n\"+\n",
"\" custom_class: (displayOptions.customClass || ''),\\n\"+\n",
"\" hide_header: (displayOptions.hideHeader === 'true'),\\n\"+\n",
"\" hide_footer: (displayOptions.showFooter === undefined || displayOptions.showFooter !== 'true'),\\n\"+\n",
"\" buttons: {\\n\"+\n",
"\" OK: {\\n\"+\n",
"\" class : \\\"btn-primary btn-ok\\\",\\n\"+\n",
"\" click: function() {\\n\"+\n",
"\" var dlg = $(\\\"#\\\" + dialogRoot + \\\" > pd_dialog\\\");\\n\"+\n",
"\" try{\\n\"+\n",
"\" pixiedust.dialogRoot = null;\\n\"+\n",
"\" $(document).trigger('pd_event', {targetDivId: sourceDivId || dialogRoot, entity: pd_controls.options.nostore_pixieapp});\\n\"+\n",
"\" return new Function('global', 'modal_obj', dlg.find(\\\"> pd_ok\\\").text().trim())(global, modal_obj);\\n\"+\n",
"\" }catch(e){\\n\"+\n",
"\" console.error(e);\\n\"+\n",
"\" return false;\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" },\\n\"+\n",
"\" Cancel: {\\n\"+\n",
"\" class : \\\"btn-cancel\\\",\\n\"+\n",
"\" click: function(){\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" };\\n\"+\n",
"\"\\n\"+\n",
"\" function resizeDialog() {\\n\"+\n",
"\" global.modalBodyStyle = $('.pixiedust .modal-body').attr('style');\\n\"+\n",
"\" global.modalFooterStyle = $('.pixiedust .modal-footer').attr('style');\\n\"+\n",
"\" $('.pixiedust .modal-body').attr('style', global.modalBodyStyle ? global.modalBodyStyle + ';padding:5px 20px !important;' : 'padding:5px 20px !important;');\\n\"+\n",
"\" if (options.hide_footer){\\n\"+\n",
"\" $('.pixiedust .modal-footer').attr('style', 'display:none !important;');\\n\"+\n",
"\" }\\n\"+\n",
"\" $(\\\".pixiedust .modal-footer\\\").find(\\\"> button:contains('OK')\\\").attr(\\\"pd_options\\\", \\\"toto=true\\\");\\n\"+\n",
"\" if (options.hide_header) {\\n\"+\n",
"\" global.modalHeaderStyle = $('.pixiedust .modal-header').attr('style');\\n\"+\n",
"\" $('.pixiedust .modal-header').attr('style', 'display:none !important;');\\n\"+\n",
"\" }\\n\"+\n",
"\" };\\n\"+\n",
"\"\\n\"+\n",
"\" function resetDialog() {\\n\"+\n",
"\" if (global.modalBodyStyle) {\\n\"+\n",
"\" $('.pixiedust .modal-body').attr('style', global.modalBodyStyle);\\n\"+\n",
"\" } else {\\n\"+\n",
"\" $('.pixiedust .modal-body').removeAttr('style');\\n\"+\n",
"\" }\\n\"+\n",
"\" if (global.modalFooterStyle) {\\n\"+\n",
"\" $('.pixiedust .modal-footer').attr('style', global.modalFooterStyle);\\n\"+\n",
"\" } else {\\n\"+\n",
"\" $('.pixiedust .modal-footer').removeAttr('style');\\n\"+\n",
"\" }\\n\"+\n",
"\" if (global.modalHeaderStyle) {\\n\"+\n",
"\" $('.pixiedust .modal-header').attr('style', global.modalHeaderStyle);\\n\"+\n",
"\" } else {\\n\"+\n",
"\" $('.pixiedust .modal-header').removeAttr('style');\\n\"+\n",
"\" }\\n\"+\n",
"\" };\\n\"+\n",
"\"\\n\"+\n",
"\" var modal_obj = modal(options);\\n\"+\n",
"\" modal_obj.addClass('pixiedust pixiedust-app ' + options.custom_class);\\n\"+\n",
"\" if (options.maximize_modal) {\\n\"+\n",
"\" modal_obj.addClass('pixiedust pixiedust-app pixiedust-maximize ' + options.custom_class);\\n\"+\n",
"\" }\\n\"+\n",
"\" modal_obj.on('shown.bs.modal', function(){\\n\"+\n",
"\" resizeDialog();\\n\"+\n",
"\" var isFF = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;\\n\"+\n",
"\" if( isFF && options.keyboard_manager){\\n\"+\n",
"\" \\n\"+\n",
"\" var KeyboardManager = require('notebook/js/keyboardmanager').KeyboardManager;\\n\"+\n",
"\" global.KMEnableProto = KeyboardManager.prototype.enable;\\n\"+\n",
"\" KeyboardManager.prototype.enable = function () {\\n\"+\n",
"\" this.enabled = false;\\n\"+\n",
"\" };\\n\"+\n",
"\" }\\n\"+\n",
"\" IPython.keyboard_manager.register_events(modal_obj);\\n\"+\n",
"\" user_controls.options.targetDivId = user_controls.targetDivId = dialogRoot;\\n\"+\n",
"\" if ( user_controls.options.dialog == 'true'){\\n\"+\n",
"\" user_controls.onDisplayDone = function(){\\n\"+\n",
"\" var dlg = $(\\\"#\\\" + dialogRoot + \\\" > pd_dialog\\\")\\n\"+\n",
"\" try{\\n\"+\n",
"\" new Function('global', 'modal_obj', dlg.find(\\\"> pd_onload\\\").text().trim())(global, modal_obj);\\n\"+\n",
"\" }catch(e){\\n\"+\n",
"\" console.error(e);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" pixiedust.dialogRoot = dialogRoot;\\n\"+\n",
"\" pixiedust.executeDisplay(pd_controls, user_controls);\\n\"+\n",
"\" });\\n\"+\n",
"\" modal_obj.on(\\\"hidden.bs.modal\\\", function () {\\n\"+\n",
"\" resetDialog();\\n\"+\n",
"\" if ( global.KMEnableProto ){\\n\"+\n",
"\" var KeyboardManager = require('notebook/js/keyboardmanager').KeyboardManager;\\n\"+\n",
"\" KeyboardManager.prototype.enable = global.KMEnableProto;\\n\"+\n",
"\" delete global.KMEnableProto;\\n\"+\n",
"\" }\\n\"+\n",
"\" pixiedust.dialogRoot = null;\\n\"+\n",
"\" });\\n\"+\n",
"\" })\\n\"+\n",
"\" },\\n\"+\n",
"\" sendEvent: function(payload, divId){\\n\"+\n",
"\" payload = payload || {};\\n\"+\n",
"\" var targetElement = event.target || event.srcElement;\\n\"+\n",
"\" divId = divId || $(targetElement).uniqueId().attr('id');\\n\"+\n",
"\" payload.targetDivId = divId;\\n\"+\n",
"\" $(document).trigger('pd_event', payload);\\n\"+\n",
"\" },\\n\"+\n",
"\" saveOutputInCell: function(curCell, content, html, msg_type){\\n\"+\n",
"\" if(curCell && curCell.output_area && curCell.output_area.outputs){\\n\"+\n",
"\" var data = JSON.parse(JSON.stringify(content.data));\\n\"+\n",
"\" if(!!data[\\\"text/html\\\"])data[\\\"text/html\\\"]=html;\\n\"+\n",
"\" function savedData(data){\\n\"+\n",
"\" \\n\"+\n",
"\" var markup='<style type=\\\"text/css\\\">.pd_warning{display:none;}</style>';\\n\"+\n",
"\" markup+='<div class=\\\"pd_warning\\\"><em>Hey, there\\\\'s something awesome here! To see it, open this notebook outside GitHub, in a viewer like Jupyter</em></div>';\\n\"+\n",
"\" nodes = $.parseHTML(data[\\\"text/html\\\"], null, true);\\n\"+\n",
"\" var s = $(nodes).wrap(\\\"<div>\\\").parent().find(\\\".pd_save\\\").not(\\\".pd_save .pd_save\\\");\\n\"+\n",
"\" s.each(function(){\\n\"+\n",
"\" var found = false;\\n\"+\n",
"\" if ( $(this).attr(\\\"id\\\") ){\\n\"+\n",
"\" var n = $(\\\"#\\\" + $(this).attr(\\\"id\\\"));\\n\"+\n",
"\" if (n.length>0){\\n\"+\n",
"\" found=true;\\n\"+\n",
"\" n.each(function(){\\n\"+\n",
"\" $(this).addClass(\\\"is-viewer-good\\\");\\n\"+\n",
"\" });\\n\"+\n",
"\" markup+=n.wrap(\\\"<div>\\\").parent().html();\\n\"+\n",
"\" }\\n\"+\n",
"\" }else{\\n\"+\n",
"\" $(this).addClass(\\\"is-viewer-good\\\");\\n\"+\n",
"\" }\\n\"+\n",
"\" if (!found){\\n\"+\n",
"\" markup+=$(this).parent().html();\\n\"+\n",
"\" }\\n\"+\n",
"\" });\\n\"+\n",
"\" data[\\\"text/html\\\"] = markup;\\n\"+\n",
"\" return data;\\n\"+\n",
"\" }\\n\"+\n",
"\" curCell.output_area.outputs = [{\\n\"+\n",
"\" \\\"data\\\": savedData(data),\\\"metadata\\\":content.metadata,\\\"output_type\\\":msg_type\\n\"+\n",
"\" }];\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\"})();\\n\"+\n",
"\"\\n\"+\n",
"\"function resolveScriptMacros(script){\\n\"+\n",
"\" script = script && script.replace(/\\\\$val\\\\(\\\\\\\"?(\\\\w*)\\\\\\\"?\\\\)/g, function(a,b){\\n\"+\n",
"\" var n = $(\\\"#\\\" + b );\\n\"+\n",
"\" var v = null;\\n\"+\n",
"\" if (n.length > 0){\\n\"+\n",
"\" if (n.is(':checkbox')){\\n\"+\n",
"\" v = n.is(':checked').toString();\\n\"+\n",
"\" }else{\\n\"+\n",
"\" v = $(\\\"#\\\" + b ).val() || $(\\\"#\\\" + b ).text();\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" if (!v && v!==\\\"\\\" && window[b] && typeof window[b] === \\\"function\\\"){\\n\"+\n",
"\" v = window[b]();\\n\"+\n",
"\" }\\n\"+\n",
"\" if (!v && v!==\\\"\\\" && pixiedust[b] && typeof pixiedust[b] === \\\"function\\\"){\\n\"+\n",
"\" v = pixiedust[b]();\\n\"+\n",
"\" }\\n\"+\n",
"\" if (!v && v!==\\\"\\\"){\\n\"+\n",
"\" console.log(\\\"Warning: Unable to resolve value for element \\\", b);\\n\"+\n",
"\" return a;\\n\"+\n",
"\" }\\n\"+\n",
"\" if (typeof v === \\\"object\\\"){\\n\"+\n",
"\" return JSON.stringify(v)\\n\"+\n",
"\" .split('\\\\\\\\').join('\\\\\\\\\\\\\\\\')\\n\"+\n",
"\" .split(\\\"'''\\\").join(\\\"\\\\\\\\'\\\\\\\\'\\\\\\\\'\\\")\\n\"+\n",
"\" .split('\\\"\\\"\\\"').join('\\\\\\\\\\\"\\\\\\\\\\\"\\\\\\\\\\\"')\\n\"+\n",
"\" }\\n\"+\n",
"\" return v.split('\\\"').join('&quot;').split('\\\\n').join('\\\\\\\\n');\\n\"+\n",
"\" });\\n\"+\n",
"\" return script;\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\"function getParentScript(element){\\n\"+\n",
"\" var scripts = [];\\n\"+\n",
"\" \\n\"+\n",
"\" $(element).parents(\\\"[pd_script]\\\").each(function(){\\n\"+\n",
"\" scripts.unshift(this.getAttribute(\\\"pd_script\\\"));\\n\"+\n",
"\" });\\n\"+\n",
"\"\\n\"+\n",
"\" \\n\"+\n",
"\" var script = \\\"\\\";\\n\"+\n",
"\" $.each( scripts, function(index, value){\\n\"+\n",
"\" if (value){\\n\"+\n",
"\" script += \\\"\\\\n\\\" + value;\\n\"+\n",
"\" }\\n\"+\n",
"\" });\\n\"+\n",
"\" return script;\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\"function preRun(element){\\n\"+\n",
"\" var preRunCode = getScriptOfType(element, \\\"preRun\\\");\\n\"+\n",
"\" if (!preRunCode ){\\n\"+\n",
"\" return true;\\n\"+\n",
"\" }\\n\"+\n",
"\" return new Function(preRunCode.trim())();\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\"function getScriptOfType(element, scriptType){\\n\"+\n",
"\" if (!element.jquery){\\n\"+\n",
"\" element = $(element);\\n\"+\n",
"\" }\\n\"+\n",
"\" var code = null;\\n\"+\n",
"\" element.find(\\\"> pd_script\\\").each(function(){\\n\"+\n",
"\" var type = this.getAttribute(\\\"type\\\");\\n\"+\n",
"\" if (type == scriptType){\\n\"+\n",
"\" code = $(this).text();\\n\"+\n",
"\" }\\n\"+\n",
"\" });\\n\"+\n",
"\" if (code){\\n\"+\n",
"\" return code.trim();\\n\"+\n",
"\" }\\n\"+\n",
"\" return code;\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\"function addOptions(command, options, override=true){\\n\"+\n",
"\" function getStringRep(v) {\\n\"+\n",
"\" if (typeof v === 'string' || v instanceof String){\\n\"+\n",
"\" v = v.replace(/'/g,\\\"\\\\\\\\\\\\'\\\");\\n\"+\n",
"\" }\\n\"+\n",
"\" return \\\"'\\\" + v + \\\"'\\\";\\n\"+\n",
"\" }\\n\"+\n",
"\" for (var key in (options||{})){\\n\"+\n",
"\" var value = options[key];\\n\"+\n",
"\" var hasValue = value != null && typeof value !== 'undefined' && value !== '';\\n\"+\n",
"\" var replaceValue = hasValue ? (key+\\\"=\\\" + getStringRep(value) ) : \\\"\\\";\\n\"+\n",
"\" var pattern = (hasValue?\\\"\\\":\\\",\\\")+\\\"\\\\\\\\s*\\\" + key + \\\"\\\\\\\\s*=\\\\\\\\s*'(\\\\\\\\\\\\\\\\'|[^'])*'\\\";\\n\"+\n",
"\" var rpattern=new RegExp(pattern);\\n\"+\n",
"\" var n = command.search(rpattern);\\n\"+\n",
"\" if ( n >= 0 ){\\n\"+\n",
"\" if (override){\\n\"+\n",
"\" command = command.replace(rpattern, replaceValue);\\n\"+\n",
"\" }\\n\"+\n",
"\" }else if (hasValue && command.search(/display\\\\s*\\\\(/) >= 0 ){\\n\"+\n",
"\" var n = command.lastIndexOf(\\\")\\\");\\n\"+\n",
"\" command = [command.slice(0, n), (command[n-1]==\\\"(\\\"? \\\"\\\":\\\",\\\") + replaceValue, command.slice(n)].join('')\\n\"+\n",
"\" } \\n\"+\n",
"\" }\\n\"+\n",
"\" return command;\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\"function computeGeometry(element, execInfo){\\n\"+\n",
"\" var parentStyles = [];\\n\"+\n",
"\" var hiddenBlockStyle = 'visibility: hidden !important; display: block !important;';\\n\"+\n",
"\" var tDiv = $(\\\"#\\\" + execInfo.targetDivId);\\n\"+\n",
"\" var tDivParents = tDiv.parents().addBack().filter(':hidden');\\n\"+\n",
"\" tDivParents.each(function() {\\n\"+\n",
"\" var currentStyle = $(this).attr('style');\\n\"+\n",
"\" parentStyles.push(currentStyle);\\n\"+\n",
"\" $(this).attr('style', currentStyle ? currentStyle + ';' + hiddenBlockStyle : hiddenBlockStyle);\\n\"+\n",
"\" });\\n\"+\n",
"\"\\n\"+\n",
"\" w = tDiv.width()\\n\"+\n",
"\" if (w) {\\n\"+\n",
"\" execInfo.options.nostore_cw= w;\\n\"+\n",
"\" }\\n\"+\n",
"\" if ($(element).parents(\\\".modal-dialog\\\").length > 0 ) {\\n\"+\n",
"\" h = tDiv.height()\\n\"+\n",
"\" if (h) {\\n\"+\n",
"\" execInfo.options.nostore_ch = h-10;\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" tDivParents.each(function(i) {\\n\"+\n",
"\" if (parentStyles[i] === undefined) {\\n\"+\n",
"\" $(this).removeAttr('style');\\n\"+\n",
"\" } else {\\n\"+\n",
"\" $(this).attr('style', parentStyles[i]);\\n\"+\n",
"\" }\\n\"+\n",
"\" });\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\"function readScriptAttribute(element){\\n\"+\n",
"\" var retValue = element.getAttribute(\\\"pd_script\\\");\\n\"+\n",
"\" var run_raw = false;\\n\"+\n",
"\" if (!retValue){\\n\"+\n",
"\" $(element).find(\\\"> pd_script\\\").each(function(){\\n\"+\n",
"\" var type = this.getAttribute(\\\"type\\\");\\n\"+\n",
"\" if (!type || type==\\\"python\\\"){\\n\"+\n",
"\" retValue = $(this).text();\\n\"+\n",
"\" run_raw = this.hasAttribute(\\\"run_raw\\\");\\n\"+\n",
"\" }\\n\"+\n",
"\" })\\n\"+\n",
"\" }\\n\"+\n",
"\" return retValue?{\\\"script\\\":retValue, \\\"run_raw\\\":run_raw}:null;\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\"function getAttribute(element, name, defValue, defValueIfKeyAlone){\\n\"+\n",
"\" if (!element.hasAttribute(name)){\\n\"+\n",
"\" return defValue;\\n\"+\n",
"\" }\\n\"+\n",
"\" retValue = element.getAttribute(name);\\n\"+\n",
"\" return retValue || defValueIfKeyAlone;\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\"function convertToBoolean(value, def){\\n\"+\n",
"\" if (value === undefined){\\n\"+\n",
"\" return def;\\n\"+\n",
"\" }\\n\"+\n",
"\" if (typeof(value) == \\\"string\\\"){\\n\"+\n",
"\" return value.toLowerCase() == \\\"true\\\";\\n\"+\n",
"\" }\\n\"+\n",
"\" return value;\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\"function readExecInfo(pd_controls, element, searchParents, fromExecInfo){\\n\"+\n",
"\" if (searchParents === null || searchParents === undefined ){\\n\"+\n",
"\" searchParents = !element.hasAttribute(\\\"pd_stop_propagation\\\");\\n\"+\n",
"\" }\\n\"+\n",
"\" var execInfo = {\\\"options\\\":{}};\\n\"+\n",
"\" $.extend(execInfo, fromExecInfo || {});\\n\"+\n",
"\" var hasOptions = false;\\n\"+\n",
"\" $.each( element.attributes, function(){\\n\"+\n",
"\" if (this.name.startsWith(\\\"option_\\\")){\\n\"+\n",
"\" hasOptions = true;\\n\"+\n",
"\" execInfo.options[this.name.replace(\\\"option_\\\", \\\"\\\")] = this.value || null;\\n\"+\n",
"\" }\\n\"+\n",
"\" });\\n\"+\n",
"\" var pd_options = resolveScriptMacros(element.getAttribute(\\\"pd_options\\\"));\\n\"+\n",
"\" if (pd_options){\\n\"+\n",
"\" var parts = pd_options.split(\\\";\\\");\\n\"+\n",
"\" $.each( parts, function(){\\n\"+\n",
"\" var index = this.indexOf(\\\"=\\\");\\n\"+\n",
"\" if ( index > 0){\\n\"+\n",
"\" hasOptions = true;\\n\"+\n",
"\" execInfo.options[this.substring(0, index)] = this.substring(index+1);\\n\"+\n",
"\" }\\n\"+\n",
"\" });\\n\"+\n",
"\" }\\n\"+\n",
"\" \\n\"+\n",
"\" $(element).find(\\\"> pd_options\\\").each(function(){\\n\"+\n",
"\" try{\\n\"+\n",
"\" var options = JSON.parse($(this).text());\\n\"+\n",
"\" hasOptions = true;\\n\"+\n",
"\" for (var key in options) { \\n\"+\n",
"\" execInfo.options[key] = resolveScriptMacros(options[key]); \\n\"+\n",
"\" }\\n\"+\n",
"\" }catch(e){\\n\"+\n",
"\" console.log(\\\"Error parsing pd_options, invalid json\\\", e);\\n\"+\n",
"\" }\\n\"+\n",
"\" })\\n\"+\n",
"\" if (convertToBoolean(execInfo.options.nostore_figureOnly, true)){\\n\"+\n",
"\" execInfo.options.nostore_figureOnly = true;\\n\"+\n",
"\" }else{\\n\"+\n",
"\" delete execInfo.options.nostore_figureOnly;\\n\"+\n",
"\" }\\n\"+\n",
"\" execInfo.options.targetDivId = execInfo.targetDivId = pd_controls.refreshTarget || element.getAttribute(\\\"pd_target\\\");\\n\"+\n",
"\" if (execInfo.options.targetDivId){\\n\"+\n",
"\" execInfo.options.no_margin=true;\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" execInfo.options.widget = element.getAttribute(\\\"pd_widget\\\");\\n\"+\n",
"\" execInfo.pixieapp = element.getAttribute(\\\"pd_app\\\");\\n\"+\n",
"\" if (execInfo.pixieapp && !execInfo.targetDivId){\\n\"+\n",
"\" execInfo.options.targetDivId = execInfo.targetDivId = $(element).uniqueId().attr('id');\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" computeGeometry(element, execInfo);\\n\"+\n",
"\"\\n\"+\n",
"\" scriptAttr = readScriptAttribute(element);\\n\"+\n",
"\" if (scriptAttr){\\n\"+\n",
"\" execInfo.script = (execInfo.script || \\\"\\\") + \\\"\\\\n\\\" + scriptAttr.script;\\n\"+\n",
"\" execInfo.script_run_raw = scriptAttr.run_raw;\\n\"+\n",
"\" }\\n\"+\n",
"\" execInfo.refresh = execInfo.refresh || (getAttribute(element, \\\"pd_refresh\\\", \\\"false\\\", \\\"true\\\") == 'true');\\n\"+\n",
"\" execInfo.norefresh = element.hasAttribute(\\\"pd_norefresh\\\");\\n\"+\n",
"\" execInfo.entity = element.hasAttribute(\\\"pd_entity\\\") ? resolveScriptMacros(element.getAttribute(\\\"pd_entity\\\")) || \\\"pixieapp_entity\\\" : null;\\n\"+\n",
"\" function applyEntity(c, e, doptions){\\n\"+\n",
"\" \\n\"+\n",
"\" doptions.prefix = pd_controls.prefix;\\n\"+\n",
"\"\\n\"+\n",
"\" pd_controls.sniffers = pd_controls.sniffers || [];\\n\"+\n",
"\" pd_controls.sniffers.forEach(function(sniffer){\\n\"+\n",
"\" c = addOptions(c, eval('(' + sniffer + ')')) \\n\"+\n",
"\" });\\n\"+\n",
"\" if (!e){\\n\"+\n",
"\" return addOptions(c, doptions);\\n\"+\n",
"\" }\\n\"+\n",
"\" if (pd_controls.entity){\\n\"+\n",
"\" c = c.replace(pd_controls.entity, pd_controls.entity+ \\\".\\\" + e );\\n\"+\n",
"\" }else{\\n\"+\n",
"\" c = c.replace(/\\\\((\\\\w*),/, \\\"($1.\\\" + e + \\\",\\\");\\n\"+\n",
"\" } \\n\"+\n",
"\" return addOptions(c, doptions);\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" var hasRefreshTarget = element.hasAttribute(\\\"pd_refresh\\\") && \\n\"+\n",
"\" element.getAttribute(\\\"pd_refresh\\\") != \\\"true\\\" &&\\n\"+\n",
"\" element.getAttribute(\\\"pd_refresh\\\") != \\\"false\\\";\\n\"+\n",
"\" if ( (!hasOptions && (execInfo.refresh || hasRefreshTarget || execInfo.options.widget) && !execInfo.script) \\n\"+\n",
"\" || (!execInfo.script && execInfo.pixieapp)){\\n\"+\n",
"\" execInfo.script = \\\"#refresh\\\";\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" var dialog = (execInfo.options.dialog == \\\"true\\\");\\n\"+\n",
"\" if ( dialog ){\\n\"+\n",
"\" execInfo.script = execInfo.script || \\\"#refresh\\\";\\n\"+\n",
"\" execInfo.refresh = true;\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" if (execInfo.script){\\n\"+\n",
"\" execInfo.script = execInfo.script.trim()\\n\"+\n",
"\" \\n\"+\n",
"\" var entity = pd_controls.entity;\\n\"+\n",
"\" if (!entity){\\n\"+\n",
"\" var match = pd_controls.command.match(/display\\\\((\\\\w*),/);\\n\"+\n",
"\" if (match){\\n\"+\n",
"\" entity = match[1];\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" if (entity){\\n\"+\n",
"\" var prolog = \\\"\\\";\\n\"+\n",
"\" if (!execInfo.script_run_raw){\\n\"+\n",
"\" console.log(\\\"Inject self with entity\\\", entity);\\n\"+\n",
"\" prolog = \\\"from pixiedust.utils.shellAccess import ShellAccess\\\\n\\\"+\\n\"+\n",
"\" \\\"self=ShellAccess['\\\" + entity + \\\"']\\\\n\\\";\\n\"+\n",
"\" }\\n\"+\n",
"\" execInfo.script = prolog +\\n\"+\n",
"\" resolveScriptMacros( getParentScript(element) ) + '\\\\n' +\\n\"+\n",
"\" resolveScriptMacros(execInfo.script);\\n\"+\n",
"\" if ( execInfo.pixieapp){\\n\"+\n",
"\" var locOptions = execInfo.options;\\n\"+\n",
"\" locOptions.cell_id = pd_controls.options.cell_id;\\n\"+\n",
"\" locOptions.prefix = pd_controls.prefix;\\n\"+\n",
"\" if (pd_controls.options.nostore_cw){\\n\"+\n",
"\" locOptions.nostore_cw = pd_controls.options.nostore_cw\\n\"+\n",
"\" }\\n\"+\n",
"\" function makePythonStringOrNone(s){\\n\"+\n",
"\" return !s?\\\"None\\\":('\\\"\\\"\\\"' + s + '\\\"\\\"\\\"')\\n\"+\n",
"\" }\\n\"+\n",
"\" function getCellMetadata(){\\n\"+\n",
"\" var cell = pixiedust.getCell(execInfo.options.cell_id);\\n\"+\n",
"\" var retValue = cell?cell._metadata:{};\\n\"+\n",
"\" return JSON.stringify(retValue || {});\\n\"+\n",
"\" }\\n\"+\n",
"\" execInfo.script += \\\"\\\\nfrom pixiedust.display.app.pixieapp import runPixieApp\\\" + \\n\"+\n",
"\" \\\"\\\\ntrue=True\\\\nfalse=False\\\\nnull=None\\\" +\\n\"+\n",
"\" \\\"\\\\nrunPixieApp('\\\" + \\n\"+\n",
"\" execInfo.pixieapp + \\\"', options=\\\" + JSON.stringify(locOptions) \\n\"+\n",
"\" + \\\",parent_command=\\\" + makePythonStringOrNone(applyEntity(pd_controls.command, execInfo.entity, execInfo.options))\\n\"+\n",
"\" + \\\",parent_pixieapp=\\\" + makePythonStringOrNone(pd_controls.options.nostore_pixieapp)\\n\"+\n",
"\" + \\\",cell_metadata=\\\" + getCellMetadata()\\n\"+\n",
"\" + \\\")\\\";\\n\"+\n",
"\" }else if ( ( hasOptions || execInfo.refresh || execInfo.entity || execInfo.options.widget) && \\n\"+\n",
"\" !execInfo.norefresh && $(element).children(\\\"target[pd_target]\\\").length == 0){\\n\"+\n",
"\" \\n\"+\n",
"\" execInfo.script += \\\"\\\\n\\\" + applyEntity(pd_controls.command, execInfo.entity, execInfo.options)\\n\"+\n",
"\" }else{\\n\"+\n",
"\" \\n\"+\n",
"\" execInfo.targetDivId=execInfo.targetDivId || \\\"pixiedust_dummy\\\";\\n\"+\n",
"\" }\\n\"+\n",
"\" }else{\\n\"+\n",
"\" console.log(\\\"Unable to extract entity variable from command\\\", pd_controls.command);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" if (!hasOptions && !execInfo.targetDivId && !execInfo.script){\\n\"+\n",
"\" if (!searchParents){\\n\"+\n",
"\" return null;\\n\"+\n",
"\" }\\n\"+\n",
"\" return element.hasAttribute(\\\"pixiedust\\\")?null:readExecInfo(pd_controls, element.parentElement);\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" if (!execInfo.script){\\n\"+\n",
"\" execInfo.script = applyEntity(pd_controls.command, execInfo.entity, execInfo.options);\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" \\n\"+\n",
"\" execInfo.nostoreMedatadata = true;\\n\"+\n",
"\"\\n\"+\n",
"\" \\n\"+\n",
"\" if ( pixiedust.dialogRoot ){\\n\"+\n",
"\" execInfo.targetDivId = execInfo.targetDivId || pixiedust.dialogRoot;\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" if (\\\"send_input_reply\\\" in execInfo.options){\\n\"+\n",
"\" execInfo.send_input_reply = execInfo.options[\\\"send_input_reply\\\"];\\n\"+\n",
"\" delete execInfo.options[\\\"send_input_reply\\\"];\\n\"+\n",
"\" }\\n\"+\n",
"\" if (\\\"answer_input_reply\\\" in execInfo.options){\\n\"+\n",
"\" execInfo.answer_input_reply = execInfo.options[\\\"answer_input_reply\\\"];\\n\"+\n",
"\" delete execInfo.options[\\\"answer_input_reply\\\"];\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" execInfo.execute = function(){\\n\"+\n",
"\" \\n\"+\n",
"\" if (!preRun(element)){\\n\"+\n",
"\" return;\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" pd_controls.sniffers = pd_controls.sniffers || [];\\n\"+\n",
"\" pd_controls.sniffers.forEach(function(sniffer){\\n\"+\n",
"\" if (this.script){\\n\"+\n",
"\" this.script = addOptions(this.script, eval('(' + sniffer + ')'));\\n\"+\n",
"\" }else{\\n\"+\n",
"\" pd_controls.command = addOptions(pd_controls.command, eval('(' + sniffer + ')'));\\n\"+\n",
"\" } \\n\"+\n",
"\" }.bind(this));\\n\"+\n",
"\"\\n\"+\n",
"\" var process_output = getScriptOfType(element, \\\"process_output\\\");\\n\"+\n",
"\" if (!process_output){\\n\"+\n",
"\" process_output = getScriptOfType($(\\\"#\\\" + this.targetDivId), \\\"process_output\\\");\\n\"+\n",
"\" }\\n\"+\n",
"\" if (process_output){\\n\"+\n",
"\" this.process_output = function(output){\\n\"+\n",
"\" new Function('output', process_output)(output);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" if ( this.options.dialog == 'true' ){\\n\"+\n",
"\" pixiedust.executeInDialog(pd_controls, this);\\n\"+\n",
"\" }else{\\n\"+\n",
"\" pixiedust.executeDisplay(pd_controls, this);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" \\n\"+\n",
"\" var refreshTarget = element.getAttribute(\\\"pd_refresh\\\");\\n\"+\n",
"\" if (refreshTarget){\\n\"+\n",
"\" if (execInfo.targetDivId == \\\"pixiedust_dummy\\\"){\\n\"+\n",
"\" \\n\"+\n",
"\" execInfo.targetDivId = \\\"pixiedust_dummy2\\\";\\n\"+\n",
"\" }\\n\"+\n",
"\" var retQueue = [execInfo];\\n\"+\n",
"\" var targets = refreshTarget.split(\\\",\\\");\\n\"+\n",
"\" $.each( targets, function(index){\\n\"+\n",
"\" var node = $(\\\"#\\\" + this);\\n\"+\n",
"\" if (node.length){\\n\"+\n",
"\" pd_controls.refreshTarget = this;\\n\"+\n",
"\" var thisexecInfo = {\\\"options\\\":{}};\\n\"+\n",
"\" thisexecInfo.options.targetDivId = this;\\n\"+\n",
"\" retQueue.push( readExecInfo(pd_controls, node.get(0), false, thisexecInfo) );\\n\"+\n",
"\" }\\n\"+\n",
"\" });\\n\"+\n",
"\" return retQueue\\n\"+\n",
"\" }\\n\"+\n",
"\"\\n\"+\n",
"\" console.log(\\\"execution info: \\\", execInfo);\\n\"+\n",
"\" return execInfo;\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\"function runElement(element, searchParents){\\n\"+\n",
"\" var pd_controls = element.getAttribute(\\\"pixiedust\\\");\\n\"+\n",
"\" if (!pd_controls){\\n\"+\n",
"\" $(element).parents(\\\"[pixiedust]\\\").each(function(){\\n\"+\n",
"\" pd_controls = pd_controls || this.getAttribute(\\\"pixiedust\\\");\\n\"+\n",
"\" });\\n\"+\n",
"\" }\\n\"+\n",
"\" var execQueue = [];\\n\"+\n",
"\" function addToQueue(execInfo){\\n\"+\n",
"\" if (Array.isArray(execInfo)){\\n\"+\n",
"\" execInfo.forEach(function(exec){\\n\"+\n",
"\" addToQueue(exec);\\n\"+\n",
"\" });\\n\"+\n",
"\" }else{\\n\"+\n",
"\" execQueue.push(execInfo);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" if (pd_controls){\\n\"+\n",
"\" pd_controls = JSON.parse(pd_controls);\\n\"+\n",
"\" \\n\"+\n",
"\" addToQueue( readExecInfo(pd_controls, element, searchParents) );\\n\"+\n",
"\"\\n\"+\n",
"\" \\n\"+\n",
"\" $(element).children(\\\"target[pd_target]\\\").each(function(){\\n\"+\n",
"\" addToQueue( readExecInfo(pd_controls, this, searchParents))\\n\"+\n",
"\" });\\n\"+\n",
"\" }\\n\"+\n",
"\" return execQueue;\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\"function filterNonTargetElements(element){\\n\"+\n",
"\" if (element && [\\\"I\\\", \\\"DIV\\\"].includes(element.tagName)){\\n\"+\n",
"\" if (!element.hasAttribute(\\\"pd_options\\\") || $(element).find(\\\"> pd_options\\\").length == 0 || element.hasAttribute(\\\"pd_render_onload\\\")){\\n\"+\n",
"\" return filterNonTargetElements(element.parentElement);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" return element;\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\"function readJSONAttribute(element, attrName){\\n\"+\n",
"\" var payload = resolveScriptMacros(element.getAttribute(attrName));\\n\"+\n",
"\" if (payload){\\n\"+\n",
"\" var parts = payload.split(\\\";\\\");\\n\"+\n",
"\" payload = {};\\n\"+\n",
"\" $.each( parts, function(){\\n\"+\n",
"\" var index = this.indexOf(\\\"=\\\");\\n\"+\n",
"\" if ( index > 0){\\n\"+\n",
"\" payload[this.substring(0, index)] = this.substring(index+1);\\n\"+\n",
"\" }\\n\"+\n",
"\" });\\n\"+\n",
"\" }else{\\n\"+\n",
"\" \\n\"+\n",
"\" $(element).find(\\\"> \\\" + attrName).each(function(){\\n\"+\n",
"\" try{\\n\"+\n",
"\" payload = JSON.parse($(this).text());\\n\"+\n",
"\" for (var key in payload) { \\n\"+\n",
"\" payload[key] = resolveScriptMacros(payload[key]); \\n\"+\n",
"\" }\\n\"+\n",
"\" }catch(e){\\n\"+\n",
"\" console.log(\\\"Error parsing \\\" + attrName + \\\", invalid json\\\", e);\\n\"+\n",
"\" }\\n\"+\n",
"\" })\\n\"+\n",
"\" }\\n\"+\n",
"\" return payload;\\n\"+\n",
"\"}\\n\"+\n",
"\"\\n\"+\n",
"\"\\n\"+\n",
"\"function processEvent(event){\\n\"+\n",
"\" if (event.pd_processed){\\n\"+\n",
"\" return;\\n\"+\n",
"\" }\\n\"+\n",
"\" \\n\"+\n",
"\" var payload = readJSONAttribute(event.target, \\\"pd_event_payload\\\");\\n\"+\n",
"\" if (payload){\\n\"+\n",
"\" pixiedust.sendEvent(payload, $(event.target).uniqueId().attr('id'));\\n\"+\n",
"\" }\\n\"+\n",
"\" execQueue = runElement(filterNonTargetElements(event.target));\\n\"+\n",
"\" \\n\"+\n",
"\" $.each( execQueue, function(index, value){\\n\"+\n",
"\" if (value){\\n\"+\n",
"\" event.pd_processed = true;\\n\"+\n",
"\" value.execute();\\n\"+\n",
"\" }\\n\"+\n",
"\" });\\n\"+\n",
"\"}\\n\"+\n",
"\"$(document).on( \\\"click\\\", \\\"[pixiedust]\\\", function(event){\\n\"+\n",
"\" if (event.target.tagName == \\\"SELECT\\\" || \\n\"+\n",
"\" (event.target.tagName == \\\"INPUT\\\" && (getAttribute(event.target, \\\"type\\\", \\\"\\\").toLowerCase() != \\\"button\\\")) || \\n\"+\n",
"\" $(event.target).is(':checkbox')){\\n\"+\n",
"\" return;\\n\"+\n",
"\" }\\n\"+\n",
"\" processEvent(event)\\n\"+\n",
"\"});\\n\"+\n",
"\"\\n\"+\n",
"\"$(document).on( \\\"change\\\", \\\"[pixiedust]\\\", function(event){\\n\"+\n",
"\" processEvent(event)\\n\"+\n",
"\"});\\n\"+\n",
"\"\\n\"+\n",
"\"\\n\"+\n",
"\"$(document).on(\\\"pd_event\\\", function(event, eventInfo){\\n\"+\n",
"\" targetDivId = eventInfo.targetDivId;\\n\"+\n",
"\" if (targetDivId){\\n\"+\n",
"\" eventHandlers = $(\\\"pd_event_handler\\\").filter(function(){\\n\"+\n",
"\" source = this.getAttribute(\\\"pd_source\\\");\\n\"+\n",
"\" if (source == \\\"*\\\" || source == targetDivId || source == eventInfo.type){\\n\"+\n",
"\" return true;\\n\"+\n",
"\" }\\n\"+\n",
"\" \\n\"+\n",
"\" return $(this).parents(\\\"[pd_target]\\\").filter(function(){\\n\"+\n",
"\" return this.getAttribute(\\\"pd_target\\\") == targetDivId;\\n\"+\n",
"\" }).length > 0;\\n\"+\n",
"\" });\\n\"+\n",
"\" eventHandlers.each(function(){\\n\"+\n",
"\" execQueue = runElement(this, false);\\n\"+\n",
"\" $.each( execQueue, function(index, value){\\n\"+\n",
"\" if (value){\\n\"+\n",
"\" if (value.targetDivId == \\\"pixiedust_dummy\\\"){\\n\"+\n",
"\" value.targetDivId = null;\\n\"+\n",
"\" }\\n\"+\n",
"\" \\n\"+\n",
"\" if (value.script){\\n\"+\n",
"\" value.script = \\\"true=True\\\\nfalse=False\\\\neventInfo=\\\"+JSON.stringify(eventInfo) + \\\"\\\\n\\\" + value.script;\\n\"+\n",
"\" }\\n\"+\n",
"\" value.execute();\\n\"+\n",
"\" }\\n\"+\n",
"\" });\\n\"+\n",
"\" });\\n\"+\n",
"\" }else if ( eventInfo.type == \\\"pd_load\\\" && eventInfo.targetNode){\\n\"+\n",
"\" var execQueue = []\\n\"+\n",
"\" function accept(element){\\n\"+\n",
"\" return element.hasAttribute(\\\"pd_widget\\\") || element.hasAttribute(\\\"pd_render_onload\\\") || element.hasAttribute(\\\"pd_refresh_rate\\\");\\n\"+\n",
"\" }\\n\"+\n",
"\" eventInfo.targetNode.find(\\\"div\\\").each(function(){\\n\"+\n",
"\" if (accept(this)){\\n\"+\n",
"\" var thisId = $(this).uniqueId().attr('id');\\n\"+\n",
"\" this.setAttribute( \\\"id\\\", thisId );\\n\"+\n",
"\" if (!this.hasAttribute(\\\"pd_target\\\") ){\\n\"+\n",
"\" this.setAttribute(\\\"pd_target\\\", this.getAttribute(\\\"id\\\") );\\n\"+\n",
"\" }\\n\"+\n",
"\" thisQueue = runElement(this, false);\\n\"+\n",
"\" var loadingDiv = this;\\n\"+\n",
"\" $.each( thisQueue, function(index, value){\\n\"+\n",
"\" if (value){\\n\"+\n",
"\" value.partialUpdate = true;\\n\"+\n",
"\" execQueue.push( value );\\n\"+\n",
"\" refreshRate = loadingDiv.getAttribute(\\\"pd_refresh_rate\\\");\\n\"+\n",
"\" if (refreshRate){\\n\"+\n",
"\" var ival = setInterval(function(){\\n\"+\n",
"\" if ($('#' + thisId).length == 0){\\n\"+\n",
"\" console.log(\\\"Clearing refresh timer\\\", ival);\\n\"+\n",
"\" clearInterval(ival);\\n\"+\n",
"\" return;\\n\"+\n",
"\" }\\n\"+\n",
"\" value.execute();\\n\"+\n",
"\" }, parseInt( refreshRate) );\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\" })\\n\"+\n",
"\" }\\n\"+\n",
"\" });\\n\"+\n",
"\"\\n\"+\n",
"\" \\n\"+\n",
"\" $.each( execQueue, function(index, value){\\n\"+\n",
"\" value.execute();\\n\"+\n",
"\" });\\n\"+\n",
"\" }\\n\"+\n",
"\" else{\\n\"+\n",
"\" if ( eventInfo.type != \\\"pd_load\\\"){\\n\"+\n",
"\" console.log(\\\"Warning: got a pd_event with no targetDivId\\\", eventInfo);\\n\"+\n",
"\" }\\n\"+\n",
"\" }\\n\"+\n",
"\"});\";\n",
" \n",
" try{\n",
" g.appendChild(document.createTextNode(code));\n",
" }catch(e){\n",
" g.text = code;\n",
" }\n",
"\n",
" s.parentNode.insertBefore(g,s);\n",
" g.onload = g.onreadystatechange = callback;\n",
" }else{\n",
" callback();\n",
" } \n",
" }else{\n",
" alert(\"An error occurred, unable to access cell id\");\n",
" }\n",
" },0);\n",
"</script>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%node\n",
"var data = [];\n",
"for (var i = 0; i < 1000; i++) {\n",
" var x = 2*Math.PI * i/ 360;\n",
" var obj = {\n",
" x: x,\n",
" i: i,\n",
" sin: Math.sin(x),\n",
" cos: Math.cos(x),\n",
" tan: Math.tan(x)\n",
" };\n",
" data.push(obj);\n",
"}\n",
"display(data);"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"C:\\Program Files\\nodejs\\npm.cmd install -s request\n",
"+ request@2.88.0\n",
"added 48 packages from 59 contributors and audited 63 packages in 2.238s\n",
"found 0 vulnerabilities\n"
]
}
],
"source": [
"npm.install('request');"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"... ... ... ...\n",
"... ...\n",
"{\"message\": \"success\", \"timestamp\": 1543457509, \"iss_position\": {\"longitude\": \"162.9057\", \"latitude\": \"-16.0398\"}}\n"
]
}
],
"source": [
"%%node\n",
"var request = require('request');\n",
"var r = {\n",
" method:'GET',\n",
" url: 'http://api.open-notify.org/iss-now.json',\n",
" json: true\n",
"};\n",
"request(r, function(err, req, body) {\n",
" print(body);\n",
"});\n",
"// {\"timestamp\": 1494857069, \"message\": \"success\", \"iss_position\": {\"latitude\": \"24.0980\", \"longitude\": \"-84.5517\"}}"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"... ..... ..... ..... ..... ... ..... ..... ....... ....... ....... ....... ....... ..... ..... ...\n"
]
}
],
"source": [
"%%node\n",
"var request = require('request');\n",
"var getPosition = function(callback) {\n",
" var r = {\n",
" method:'GET',\n",
" url: 'http://api.open-notify.org/iss-now.json',\n",
" json: true\n",
" };\n",
" request(r, function(err, req, body) {\n",
" var obj = null;\n",
" if (!err) {\n",
" obj = body.iss_position\n",
" obj.latitude = parseFloat(obj.latitude);\n",
" obj.longitude = parseFloat(obj.longitude);\n",
" obj.time = new Date().getTime(); \n",
" }\n",
" callback(err, obj);\n",
" });\n",
"};"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"... ...\n",
"{\"longitude\": 163.728, \"latitude\": -14.9976, \"time\": 1543457530585}\n"
]
}
],
"source": [
"%%node\n",
"getPosition(function(err, data) {\n",
" print(data);\n",
"});\n",
"// {\"latitude\": 50.5736, \"longitude\": -99.3493, \"time\": 1494422942373}"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment