ASKSAGE: Sage Q&A Forum - Latest question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 21 Apr 2018 10:51:40 -0500Sagecell with code hosted in GitHubhttps://ask.sagemath.org/question/42115/sagecell-with-code-hosted-in-github/I would like to embed a Sage Cell in a webpage whose content comes from a GitHub `.py` file, so that changes in this file are immediately shown in the webpage. I have tried to use `javascript` / `jquery` like this (with the standard scripts in the head) and with some variations:
<div class="sage"><script type="text/x-sage" id="sage1"></script></div>
<script>$('#sage1').load("https://rawgit.com/path_to_the_file.py");</script>
and it sometimes work, but not always. I guess it has to do with the order of all the scripts involved in the process. Which would be the most appropiate and clean way to inject such code in a Sage Cell?
**EDIT:** I would like to show the input cell together with the input code, for educational purposes. So the content of the input cell has to be replaced with the content of the `.py` file.jepstraSat, 21 Apr 2018 10:51:40 -0500https://ask.sagemath.org/question/42115/Loaded event for sagecellhttps://ask.sagemath.org/question/36741/loaded-event-for-sagecell/ Hi folks,
I need to call some javascript functions only after a sagecell has been fully loaded on my webpage. I've tried mutation observers and such but nothing is quite right. Does the sagecell emit an event when it has finished doing its thing?
More specifically, I need to resize an outer wrapper-div in the html whenever the sagecell resizes, as it keeps getting cut off. So this would need to work with interacts as well.ShaiSun, 26 Feb 2017 13:36:17 -0600https://ask.sagemath.org/question/36741/Embed 3rd party javascript library in worksheethttps://ask.sagemath.org/question/26949/embed-3rd-party-javascript-library-in-worksheet/ Hi
How might I embed a 3rd party javascript library in a Sage worksheet? I've tried something along the lines of:
%html
<script src="./path/to/local/javascript_file.js"></script>
...
where "./path/to/local/javascript_file.js" is a path in my project folder. However, this doesn't appear to work.
Any suggestions?
Thanks in advance,
BlairbsdzWed, 27 May 2015 08:37:24 -0500https://ask.sagemath.org/question/26949/3D plotting in the cloud with jmolhttps://ask.sagemath.org/question/30052/3d-plotting-in-the-cloud-with-jmol/ As I understand it, the sage cloud is using three.js for 3D plotting. It's usable, but has some real issues. Based on my experience, jmol is still better, but has been undesirable because of dependence on java. But there is a javascript version, jsmol, that appears to work reasonably well. It's slower than java, and I think slower than three.js, but in some circumstances the quality is better.
Is there a plan, or maybe a chance of a plan, to make jsmol an option in the cloud? One of my needs is to put 3D plots in web pages, without java. Jsmol lets me do it, and from the sage cloud I can export the needed jmol archive, but it would be nice to preview in jsmol as well. David GuichardThu, 15 Oct 2015 19:33:06 -0500https://ask.sagemath.org/question/30052/Is it possible to have interactive graphics (e.g. a HTML5/Javascript canvas) in a Sage notebook?https://ask.sagemath.org/question/29557/is-it-possible-to-have-interactive-graphics-eg-a-html5javascript-canvas-in-a-sage-notebook/ Hi, I'd like to have a canvas in which I can drag objects with the mouse and each mouse motion event triggers a Sage calculation that will update some other object in the cancas. Is that possible?R.OldenburgThu, 24 Sep 2015 04:34:45 -0500https://ask.sagemath.org/question/29557/Calling SageMath functions from Javascripthttps://ask.sagemath.org/question/26699/calling-sagemath-functions-from-javascript/ I ask the question and I have to admit that I'm a bit confused on the way to be precise to ask the question... Sorry for that!
Anyhow, I'm using from time to time SageMath on a local machine. I have seen that SageMath is also offering access from a server [Sage Cell Server][1]. If I understand well this is a way to access **SageMath interpreter** from a web browser.
But this doesn't provide access to the "base functions" of SageMath from JavaScript. That would be a kind of "wrapping" of SageMath basic functions in JavaScript calling a server. Is that possible?
Note: I also asked the question on StackOverflow
[1]: https://sagecell.sagemath.org/static/about.html?v=15adefe8b7e89fcf49eda7af5303abd4LaptopFri, 01 May 2015 12:51:55 -0500https://ask.sagemath.org/question/26699/JSON and basic sage typeshttps://ask.sagemath.org/question/10312/json-and-basic-sage-types/Is there any package that produces a JSON string from sage dictionary containing "basic" sage types ?
Something like [1]:
class jsonmegua(json.JSONEncoder):
def default(self, o):
try:
if type(o)==sage.rings.integer.Integer:
json_obj = int(o)
elif type(o)==sage.rings.real_mpfr.RealLiteral:
json_obj = float(o)
elif type(o)==sage.rings.real_mpfr.RealNumber:
json_obj = float(o)
elif type(o)==sage.symbolic.expression.Expression:
json_obj = latex(o)
else:
json_obj = o
except TypeError:
pass
else:
return json_obj
# Let the base class default method raise the TypeError
return JSONEncoder.default(self, o)
[1] http://docs.python.org/2/library/json.htmlPedroTue, 02 Jul 2013 13:17:27 -0500https://ask.sagemath.org/question/10312/cell_resizer and the notebook CSShttps://ask.sagemath.org/question/8307/cell_resizer-and-the-notebook-css/I'm changing font sizes depending on whether a text area is being edited or not, and the enclosing text area height is being programmatically set wrong somewhere. I'm trying to figure out the right way of fixing this-- do I need to start editing javascript, and how do I do so in a way that doesn't break anything else or make updating Sage a nightmare.
Here's some more detail on the problem:
I've created a notebook.css (inserted at the bottom of this post) to reduce the font size on the input cells, because I want most of the focus on the text cells and result cells. That's a pain when I edit, so I increase the font size when the cell is being edited (I'm realizing it would be best to increase the font under a hover, but first things first).
The problem I'm having is that the font is changing as I'd hoped, but the size of the surrounding textarea is sized to hold the larger font even when the smaller font is displayed. It looks like this is happening because the "height" style is being set explicitly on a cell by cell basis, and it looks like that's happening in some javascript routine.
I've dug a bit into the javascript files, but I'm quickly getting lost. I'm not sure this is where the issue is, but it's my best guess so far. If someone could point me at the right file and where they reside in a Sage.app install, that would be a great help already.
Ideally I'd like a way to adjust this without having to modify the standard install. notebook.css is nice because it's local, but I'm not sure I can overload a javascript function in the same way.
My overall objective:
I'm trying to customize my notebook styling to further my goal of using Sage as a live documentation tool. I'm an engineer, and I want to use Sage to both help develop new designs and to document them-- as such, the math is essentially a means to an end. I want the emphasis on the results, but I want to retain the math/Python both so I can reconstruct my logic later, and to assist in peer review.
Here's my notebook.css:
h1 {font-size:32pt; color:rgb(50,200,200);}
div.text_cell p {font-size:14pt;}
textarea.cell_input {font-size:8pt; color:rgb(75,75,75);}
div.worksheet * {background-color:rgb(240,240,240);}
div.worksheet textarea.cell_input_active {background-color:transparent;}
div.worksheet span.typeset * {background-color:transparent;}
tr {border-color:rgb(240,240,240);}
td {border-left-color: rgb(240,240,240);}
Thanks--
Greg
G BWed, 07 Sep 2011 15:23:39 -0500https://ask.sagemath.org/question/8307/Sage and Javascripthttps://ask.sagemath.org/question/9913/sage-and-javascript/Hi all,
I have never used Sage seriously and I have a newbie question.
I would like to use Sage Server as a math processor and read query results (i.e. raw data) though a kind of rest api. In this way, I could integrate my Javascript application with complex math.
I had a quick look at Sage Notebook and I saw that it uses json to interact with the server.
However, it seems (but I might be wrong) that this json is tightly coupled with the Notebook interface.
I was wondering:
1. If the Notebook api is documented anywhere.
2. If there are pure Javascript decoupled gui which use Sage.
Thanks a lot,
Marco
MarcosFri, 15 Mar 2013 05:30:45 -0500https://ask.sagemath.org/question/9913/Is sage supported with javascript?https://ask.sagemath.org/question/8722/is-sage-supported-with-javascript/If I am converting Python code to JavaScript, will it preserve the Sage functions and stuff? If so, which conversion tool is best?
Perhaps a better question: More generally, what do people think is the best way to implement Python code w/ Sage on a website?erossSun, 19 Feb 2012 08:12:08 -0600https://ask.sagemath.org/question/8722/Using javascript towards regular Sage clusterhttps://ask.sagemath.org/question/8421/using-javascript-towards-regular-sage-cluster/ive been thinking how we could get more interactivity; and I actually [got processing.js to work inside Sage](http://sagenb.org/home/pub/3445/). Scroll down and move the mouse around in the gray box (pun intended) to see what happens.
So can I get Sage to communicate with external javascrip libraries and how is it done
for jquery, jsMath in Sage?staffanFri, 28 Oct 2011 03:14:50 -0500https://ask.sagemath.org/question/8421/a functional java applet for 2d plotshttps://ask.sagemath.org/question/8387/a-functional-java-applet-for-2d-plots/3d plotting with jmol is great idea. However, all what I find for 2d plotting generates a picture only. I'd like to have an applet for that which supports cursors, zooming, maybe hiding certain plotted lines and other interactive control elements. Of course, this can be somehow done with @interact, but the applet would work much faster than the link browser-worksheet-sage. At least, an attempt to introduce cursor did not seem to have a handy result:
p1=plot (sin(x))
@interact
def _(b = slider(-1, 1, 0.01, default=0.5, label='cursor')):
p2=line(((b,-1),(b,1)), color='green')
show(p1+p2,xmin=-1,xmax=1,ymax=1,ymin=-1)
Does anybody know if there is an easy way to do this, or if there is not, where one may start integrating such an applet into sage? There are a number of open-source graphing applets. [Here](http://academic.sun.ac.za/mathed/java/Index.htm) is the example, maybe, even not the best one.
ADuC812Mon, 17 Oct 2011 03:35:53 -0500https://ask.sagemath.org/question/8387/