-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add auto run on load #9
Comments
This would be quite useful. I've been messing around to accomplish a few things:
Few hurdles I had to cross:
In case you'd like to have a look: <wc-code-zone mode="python" theme="monokai">
<wc-code id="lib-code" src="wff.py" readonly>
</wc-code>
<wc-code id="user-code" src="main.py">
</wc-code>
</wc-code-zone>
<script>
function check_and_delay() {
if (WCCode.zones.get(0).interpreter && WCCode.zones.get(0).interpreter.initialized) {
$("#lib-code input")[0].click();
$('.wc-code-console').remove();
$("#user-code input")[0].click();
var console_output = `
<div class="card border-dark mb-3">
<div class="card-header"><h5 class="card-title">Output</h5></div>
<div class="card-body text-dark">
<pre class="wc-code-console2"></pre>
</div>
</div>`;
$('#user-code').append(console_output);
WCCode.zones.get(0).console.addEl = function (t) { $('#user-code .wc-code-console2').append(t + '\n'); };
WCCode.zones.get(0).console.addText = function (t) { WCCode.zones.get(0).console.addEl(t) };
WCCode.zones.get(0).console.clear = function () { $('#user-code .wc-code-console2').html(''); };
console.log('Ready!');
} else {
setTimeout(check_and_delay, 500);
}
}
$(document).ready(function () {
$('#lib-code').hide();
check_and_delay();
});
</script> I'll be using this common pattern -- one boilerplate chunk of code (here, Thanks for the great project! |
Holy crap!, I'm amazed by how much code you managed to figure out despite the lack of documentation (I'm so sorry, I was quite naive when I created this library). I will look into this issue, I think this code would also be benefited if there was an on-load event that would be triggered when the code is run PRs would be appreciated, I will try to get to this when I find the time |
also heads-up this entire codebase needs a massive rewrite, and move to the shadow dom (which I should have done to begin with), (and needs to get rid of the "constructor" completely) Also about jquery, wc-code utilizes the iodide project for python underneath, the last example at https://alpha.iodide.io/tryit/ is how you may import javascript libraries in python |
No description provided.
The text was updated successfully, but these errors were encountered: