Peter
03/30/2021, 6:44 PMaltavir
03/31/2021, 5:29 AMroman.belov
03/31/2021, 8:54 AMPeter
03/31/2021, 11:58 AMIlya Muradyan
04/01/2021, 8:01 AM<div id="kotlin_out_0"/>
<script type="text/javascript">
if(!window.kotlinQueues) {
window.kotlinQueues = {};
}
if(!window.kotlinQueues["testLib2"]) {
var resQueue = [];
window.kotlinQueues["testLib2"] = resQueue;
window["call_testLib2"] = function(f) {
resQueue.push(f);
}
}
(function (){
var modifiers = [(function(script) {
script.src = "<https://cdn.plot.ly/plotly-latest.min.js>"
}),
(function(script) {
script.textContent = "function test_fun(x) {\n return (\"var\" + x);\n}\n"
script.type = "text/javascript";
})]
var e = document.getElementById("kotlin_out_0");
modifiers.forEach(function (gen) {
var script = document.createElement("script");
gen(script)
script.onload = function() {
window["call_testLib2"] = function(f) {f();};
window.kotlinQueues["testLib2"].forEach(function(f) {f();});
window.kotlinQueues["testLib2"] = [];
};
script.onerror = function() {
window["call_testLib2"] = function(f) {};
window.kotlinQueues["testLib2"] = [];
var div = document.createElement("div");
div.style.color = 'darkred';
div.textContent = 'Error loading resource testLib2';
document.getElementById("kotlin_out_0").appendChild(div);
};
e.appendChild(script);
})
})()
</script>
It gives you an ability to use your library objects inside the wrapper. For example, if the library defines Plotly object, you may write the following in your JS:
call_testLib2(() => { Plotly.plot(...) })
But I can't recall if it works both in Notebook and Labaltavir
04/01/2021, 8:04 AMPeter
04/04/2021, 10:05 AM