<br><br><div class="gmail_quote">On Tue, Jan 8, 2013 at 2:04 PM, Brian Granger <span dir="ltr"><<a href="mailto:ellisonbg@gmail.com" target="_blank">ellisonbg@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Using the JS Plugins branch, you can use the following model:<br>
<br>
* Write a JS plugin that has all of the javascript code you need - you<br>
can do whatever you want.<br>
* That Js plugin will declare a handler for a particular type of data.<br>
* You can then publish JSON data to that handler using appropriate Python calls.<br>
<br>
You shouldn't ever need to use the existing Javascript object to write<br>
your JS code.<br></blockquote><div><br></div><div>I don't think doing away with inline js is remotely feasible.</div><div>For security reasons, we have to make decisions like:</div><div><br></div><div>on load, do not run raw js, because it could do terrible things without the user being aware.</div>

<div><br></div><div>But removing the general ability to run js without installing new files on the nb *server* cannot possibly be the long-term solution.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<br>
Cheers,<br>
<br>
Brian<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
On Tue, Jan 8, 2013 at 1:11 PM, lecast <<a href="mailto:martin.zmk@gmail.com">martin.zmk@gmail.com</a>> wrote:<br>
> Thx. I will have a look at both the repository and the pull.<br>
><br>
> Returning Javascript() or HTML() is not exactly what I need. In general I<br>
> always need  to publish both html and javascript within a function so that<br>
> function that would correspond to make_table() from ipy_table creates both<br>
> the element and the script that populates that element. But this is mute<br>
> here, since I couldn't find a way to copy final elements from the window and<br>
> saving them in the notebook for good, the only thing that actually is saved<br>
> is the final html object.<br>
><br>
> I don't use inline JS anywhere there. But, if you prevent inline JS in<br>
> output then you will also prevent a lot of interactivity on final output<br>
> that e.g. d3 generates. I mean you need to be able to have things like<br>
> onClick etc. But if you mean that you will prohibit me from saving<br>
> javascript in any form in the notebook, then I will probably have to stop<br>
> pulling the new versions... Right now I spend all my time in Notebook, i.e.<br>
> I wrote a script that converts notebooks to latex and I just write my papers<br>
> in Notebook. It is nice since I see my math instantly, but I need to be able<br>
> to embed some javascript that appears only in those notebooks that are<br>
> really papers, e.g. to replace references or make highlights (<br>
> <a href="http://i46.tinypic.com/163qyg.png" target="_blank">http://i46.tinypic.com/163qyg.png</a> ).<br>
><br>
> Customjs is ok unless you send the notebook to someone and don't tell them<br>
> they need to have it as well. I wanted something that produces output that<br>
> is easily replicable.<br>
><br>
><br>
><br>
> Z wyrazami szacunku,<br>
> Marcin Zamojski<br>
><br>
><br>
> On Tue, Jan 8, 2013 at 8:56 PM, Matthias Bussonnier [via Python] <[hidden<br>
> email]> wrote:<br>
>><br>
>> Hi !<br>
>><br>
>> It look really great :<br>
>><br>
>> A few comment :<br>
>><br>
>> Obstacle 1<br>
>> def x():<br>
>>         from IPython.core.display import Javascript<br>
>>         Javascript('alert("a")')<br>
>> x()<br>
>><br>
>> you probably want to `return Javascript('alert("a")')`<br>
>> Am I wrong ?<br>
>><br>
>><br>
>> Obstacle 2:<br>
>>  same : `return HTML()` I guess...<br>
>><br>
>> Please, please, please don't inline script.<br>
>> We will in anyway prevent script in output so this will become useless<br>
>> anyway.<br>
>> Which will deprecate _js_repr_ (at least make it useless) but Brian<br>
>> Json-handler branch<br>
>> ill work much better to do what you want.<br>
>><br>
>> Obstacle 3/Obstacle 4<br>
>> Will be solve with brian Json Handler branch.<br>
>><br>
>> You probably want to inject your own library in the notebook,<br>
>> which can be done via custom.js<br>
>><br>
>> draft doc :<br>
>> <a href="http://elacave.lmdb.eu/~carreau/yui/classes/IPython.customjs.html" target="_blank">http://elacave.lmdb.eu/~carreau/yui/classes/IPython.customjs.html</a><br>
>> use $.getScript(url)<br>
>> for example :<br>
>> $.getScript('d3.min.js') in you have d3.min.js in<br>
>> .ipython/profile_xxx/static/js/d3.min.js<br>
>><br>
>> You might be interesting in<br>
>> <a href="http://epmoyer.github.com/ipy_table/" target="_blank">http://epmoyer.github.com/ipy_table/</a><br>
>><br>
>> To join effort.<br>
>><br>
>> Thanks.<br>
>> --<br>
>> Matthias<br>
>><br>
>><br>
>><br>
>><br>
>> Le 8 janv. 2013 à 17:26, lecast a écrit :<br>
>><br>
>> > This is a new thread but it is born out and related to a  previous<br>
>> > discussion<br>
>> ><br>
>> > <<a href="http://python.6.n6.nabble.com/experiment-remote-execution-of-jquery-and-d3-code-into-the-browser-via-ipython-td4633053.html#a4955237" target="_blank">http://python.6.n6.nabble.com/experiment-remote-execution-of-jquery-and-d3-code-into-the-browser-via-ipython-td4633053.html#a4955237</a>><br>


>> > . The goal there was to live update figures created with d3js in IPython<br>
>> > Notebook. It was suggested that a solution would be to use widgets,<br>
>> > which I<br>
>> > have to admit I did not have time to understand so instead I decided to<br>
>> > create something that produces the end product I was aiming at, i.e.<br>
>> > take<br>
>> > output from Python, use d3js to create a table/figure, use some<br>
>> > blackbox,<br>
>> > have the output visible in the notebook (or be able to save it elsewhere<br>
>> > as<br>
>> > svg/html/png/etc).<br>
>> ><br>
>> > You can find an example notebook with a lot of custom tables and some<br>
>> > figures  here <<a href="http://nbviewer.ipython.org/4484816/ipyD3sample.ipynb" target="_blank">http://nbviewer.ipython.org/4484816/ipyD3sample.ipynb</a>>  .<br>
>> > They are all created based on data from Python, rendered in PhantomJs<br>
>> > (in<br>
>> > that case I just copy the html, but PhantomJs allows for conversion to<br>
>> > other<br>
>> > formats), and then published in the notebook.<br>
>> ><br>
>> > I created it for myself, so there is hardly any commenting in the file<br>
>> > (I<br>
>> > know, bad), but I have been using it for a few months now and it works<br>
>> > really well. D3js has some great modern visualizations coded in and it<br>
>> > takes<br>
>> > only a few days to learn the syntax by doing.<br>
>> ><br>
>> > Personally I think it would be really nice to make it into an<br>
>> > extension/package, but I lack experience/time to do that.<br>
>> ><br>
>> ><br>
>> ><br>
>> > --<br>
>> > View this message in context:<br>
>> > <a href="http://python.6.n6.nabble.com/D3js-and-IPython-tp5001661.html" target="_blank">http://python.6.n6.nabble.com/D3js-and-IPython-tp5001661.html</a><br>
>> > Sent from the IPython - Development mailing list archive at Nabble.com.<br>
>> > _______________________________________________<br>
>> > IPython-dev mailing list<br>
>> > [hidden email]<br>
>> > <a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
>><br>
>> _______________________________________________<br>
>> IPython-dev mailing list<br>
>> [hidden email]<br>
>> <a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
>><br>
>><br>
>> ________________________________<br>
>> If you reply to this email, your message will be added to the discussion<br>
>> below:<br>
>> <a href="http://python.6.n6.nabble.com/D3js-and-IPython-tp5001661p5001692.html" target="_blank">http://python.6.n6.nabble.com/D3js-and-IPython-tp5001661p5001692.html</a><br>
>> To unsubscribe from D3js and IPython, click here.<br>
>> NAML<br>
><br>
><br>
><br>
> ________________________________<br>
> View this message in context: Re: D3js and IPython<br>
><br>
> Sent from the IPython - Development mailing list archive at Nabble.com.<br>
><br>
</div></div><div class="im HOEnZb">> _______________________________________________<br>
> IPython-dev mailing list<br>
> <a href="mailto:IPython-dev@scipy.org">IPython-dev@scipy.org</a><br>
> <a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
><br>
<br>
<br>
<br>
</div><div class="im HOEnZb">--<br>
Brian E. Granger<br>
Cal Poly State University, San Luis Obispo<br>
<a href="mailto:bgranger@calpoly.edu">bgranger@calpoly.edu</a> and <a href="mailto:ellisonbg@gmail.com">ellisonbg@gmail.com</a><br>
</div><div class="HOEnZb"><div class="h5">_______________________________________________<br>
IPython-dev mailing list<br>
<a href="mailto:IPython-dev@scipy.org">IPython-dev@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
</div></div></blockquote></div><br>