The following off-list exchange between Rob and Rado preceded Rado's first post to this thread. I apologize for mis-paraphrasing Rado's remarks, Rob's response to which Rado has, in some respects, already replied.
Rob Beezer wrote: > Radoslav Kirov wrote: >> [about an editor window that communicates directly with the server] > > Yes, this is more what I have in mind. But why not have the editor open > as a method call on the graph? This would make the import button > unnecessary, and there could be several windows open at once for several > different graphs. In a way you would be binding the window to the > graph, as a sort of property, I guess. > > I think Jason is thinking larger and is looking for a framework that > will also allow for things like equation editors, or maybe pallettes for > symbols, that sort of thing. > > Radoslav Kirov wrote: >> [about the disadvantage of opening a window just for quick changes, >> plus the potential overhead of real-time client-server communication] > > I hadn't considered the communication cost to a remote server. But then > I don't think it has to be that expensive. I would not send the > "dragging" information for a vertex, or highlighting a vertex for an > edge change. I would send: vertex addition, vertex removal, new vertex > location, edge addition, edge removal. As minor local changes, its not > much information, and if the Graph class doesn't have the right methods > to deal with them, we can add them. and they probably only happen at > the rate of every few seconds. Rado wrote: > Alright, it was a struggle debugging javascript (i feel sorry for the > people that have to code in it for a living), but finally I am done > with the hook between the graph editor and sage notebook. Here is the > first prototype: > > 1) get http://www.math.uiuc.edu/~rkirov2/sage/graph_editor.zip > > 2) exact all files in %sage_dir%/local/notebook/javascript/ > graph_editor/ > (create that folder it wont be there) > > 3)open a notebook and run > load %sage_dir%/local/notebook/javascript/graph_editor/jquery.py > (replacing sage_dir with your sage directory) > or just copy/paste the file in question > > 4)try > g=graphs.PetersenGraph() > graph_editor(g) > > A few known bugs(limitations): > - update button only updates the cell text, its up to you to hit > "evaluate" to send the new data to the server (can't do much about it, > since i dont want to mess with the server-side code). > - update puts graph named g by default. > - the remove edge by draggin only works in the iframe box > > I agree with Jason that with the power of js these days, we can make > many cool plug-ins for SAGE (like the graph editor;) ). However, > practice it was quite a struggle to get this to work (it took me > almost as long to make it work with SAGE as to write the thing). > > We have to decide how would plug-ins work: > > 1)Make a basic API for plug-ins to communicate directly with SAGE > server in some generic form (i think JSON is a standard for that > although i never used it). Currently, the server is made to talk only > to a cell because it spits out things like cell id and such. > ~or~ > 2)Force all plug-ins go through updating cells first (like the > graph_editor does now for lack of alternative) by jquery trickery. I > dont like that this ties any client implementation with the notebook, > which is already quite heavy machinary (i stared at js.py for quite > some time). But then again this is already working, so no rewrite > needed. > > Also, does anyone know a more graceful way of passing variables to an > iframe other than the current href="graph_editor?g=.....data..." ? Some ways, not necessarily graceful... Pushed by the parent, if the timing is right: var push = function (data) { $('#iframe1').contents().find('div#hidden').val(data); } push(data); Or call a frame's function: $('#iframe1')[0].contentWindow.do_something(data); A somewhat safer alternative: var ifr = $('<iframe> ... </iframe>'); ifr.bind('load', function () { push(data) }); $('#something').append(ifr); But 'load' can fire too early in Opera. A generic probabilistic workaround: setTimeout('push(data)', 1000); or var wrap = function () { push(data); } setTimeout(wrap, 1000); Another way, pulled by the frame: $(document).ready({ data = $('#textarea1', top.document).val(); }); --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---